Search code examples
javascriptgetazure-devopsazure-devops-extensions

"401 Unauthorized" while using vss-web-extension-sdk for requests


I am in the process of creating a report, generated and organized from various VSTS API calls. I am running into a wall using the vss.sdk to make the requests to the git rest api. The request seemed easy enough, following from examples The Core Client SDK Documentation

VSS.require(["VSS/Controls","VSS/Service", "VSS/Controls/TreeView", "TFS/VersionControl/GitRestClient"], function(
  VSS_Controls,
  VSS_Service,
  TreeView,
  GitClient){

//...Various Functions are Defined...

module.exports.getRepos = async function(Project){ 
  var client = VSS_Service.getCollectionClient(GitClient.GitHttpClient2_1);
  return await client.getRepositories(Project);
}

The response I get back is "401: error: TF400813: The user '####MyUserID####' is not authorized to access this resource."

My tests were done on my personal VSTS account where I am an Administrator, so it shouldn't be an issue with my permissions.

Any and all thoughts\suggestions\prayers\ideas are appreciated!


Solution

  • It is based on the Scopes to generate the access token, so check the scopes of your extension (e.g. vso.code_manage)