microsoft / azure-devops-extension-sample

Sample web extension for Azure DevOps
MIT License
240 stars 159 forks source link

WorkItemIcons and Scopes #41

Open RoyRosenberg opened 5 years ago

RoyRosenberg commented 5 years ago

Hello, I used this repo to get the icons of the work item types var iconList = await client.getWorkItemIcons(); console.log("work item icons", iconList);

And got a CORS issue: workItemIcons:1 GET http://.../DefaultCollection/_apis/wit/workItemIcons 401 (Unauthorized) Hub.html:1 Access to fetch at 'http://.../DefaultCollection/_apis/wit/workItemIcons' from origin 'http://...' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I guessed it's a scopes issue but I don't know which scope to use, I currently use

"scopes": [ "vso.work_full" ]

But it's not enough and it's not written in: https://docs.microsoft.com/en-us/azure/devops/extend/develop/manifest?view=azure-devops#scopes Please help, which scope Should I use? 10x!

thecherrytree commented 4 years ago

Ever figure this one out Roy?

ronnyek commented 4 years ago

If I had to guess, I'd guess that this is actually if you are changing the baseURI for testing purposes, and therefor loading the extension source from your local machine vs actually being hosted in azure devops. (honestly probably nothing to do with the scopes unless you are seeing permissions related failures).

I've happened across this issue for the very same reason, and am investigating ways to override cors policies in the js/ts clients. I'll update this issue if I figure it out.

ronnyek commented 4 years ago

I stand corrected, I updated the scopes in the extension .json file and repushed my extension, and now am able to execute those API commands, even when loading from my local dev machine

Gitrathirad commented 4 years ago

@ronnyek - Please share the scopes that working for you.

matthewtabor-itrellis commented 3 years ago

@ronnyek can you please share what scopes you needed to add here

yonail commented 3 years ago

I'm also facing this CORS issue if someone can explain how to handle it locally

jasonericdavis commented 2 years ago

I came across this issue trying to figure out the same thing. This issue helped me to figure out the answer that I was looking for https://github.com/microsoft/azure-devops-extension-api/issues/39