Visual Studio Online REST API在使用OAuth进行身份验证时出现401 Unauthorized错误 [英] Visual Studio Online REST API gives 401 Unauthorized error while authenticating using OAuth

查看:770
本文介绍了Visual Studio Online REST API在使用OAuth进行身份验证时出现401 Unauthorized错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有Visual Studio Online的工作帐户(现在称为Visual Studio Team Services),我打算使用REST API来集成Web应用程序我正在发展。因此,根据此处的文档(https://www.visualstudio.com/integrate/get-started/auth/oauth) I
由app注册,然后使用App ID授权应用程序回调我的应用程序的URL,然后发布收到的App Secret和授权代码,以获取令牌。一切都按预期工作,我能够成功调用REST API。

I have a work account with Visual Studio Online (now called Visual Studio Team Services), and I intend to use the REST APIs to integrate a web application that I am developing. So, as per the documentation here (https://www.visualstudio.com/integrate/get-started/auth/oauth) I registered by app, then used the App ID to authorized the app with the callback URL to my app which then posts the App Secret and Authorization Code received, to get the token. Everything worked as expected, and I was able to call the REST APIs successfully.

然后,我尝试用我的同事帐户做同样的事情。我能够让他注册应用程序,对其进行授权(使用稍微不同的回调URL,因为相同的回调URL不能在同一个VSO帐户上多次使用)
并且还获得访问令牌和刷新令牌。但是,当我使用该访问令牌调用REST API时,我收到401 Unauthorized错误。我确保了以下几点:

Then, I tried doing the exact same thing with one of my colleagues account. I was able to get him to register the app, authorize it (with a slightly different callback URL because the same callback URL can't be used more than once on the same VSO account) and also get an access token and a refresh token. However, when I use that access token to call the REST APIs, I get a 401 Unauthorized error. I have ensured the following things:

1。让我的同事使用兼容的浏览器登录Visual Studio Online,并确保他可以访问它。

1. Getting my colleague to log into Visual Studio Online using a compatible browser, and making sure he has access to it.

2。将他的帐户添加到集合中的所有项目,作为利益相关者。

2. Adding his account to all the projects in the collection, as a stakeholder.

3。让他注册应用程序时,我确保选择了正确的范围,并且我调用REST API仅使用在注册应用程序期间选择的范围。

3. While having him register the app, I made sure the proper scopes are selected, and I am calling the REST APIs to use only the scopes that were selected during registering the app.

4。访问令牌尚未过期。

4. The access token has not expired.

以上都没有解决我的问题。出于好奇,我甚至让其他几个同事尝试使用OAuth进行身份验证(使用与我的帐户完全相同的代码),并且所有人都获得了401 Unauthorized。似乎只有我的账户
有效。我已经对此进行了大约一个月的故障排除,并且已经用尽了我能想到的所有可能的选项。我甚至用这里的codeplex示例(http://vsooauthclientsample.codeplex.com/)仔细检查了我的身份验证代码,并确保我正在做的
正是在样本中完成的工作。我甚至使用了样本本身,但结果是一样的;我的帐户已通过身份验证,但没有其他帐户。

None of the above has solved my problem. Out of curiosity, I even got a couple other colleagues to try authenticating using OAuth (using the exact same code that I used for my account) and all of them are getting 401 Unauthorized. It seems like only my account works. I have been troubleshooting this for about a month now, and have exhausted all the possible options I could think of. I even double-checked my authentication code with the codeplex sample here (http://vsooauthclientsample.codeplex.com/), and made sure that I am doing exactly what is being done in the sample. I even used the sample itself, but the result was the same; my account is authenticated, but no other account is.

所以,我的问题很简单,我需要做的是为了使Visual Studio Online成员能够完成使用OAuth?任何帮助将不胜感激。

So, my question here is simply, what am I missing that needs to be done in order for a Visual Studio Online member to be able to use OAuth? Any help would be greatly appreciated.

推荐答案

Hello Waqas Shah,

Hello Waqas Shah,

我们目前正在检查在此,很快就会回复你,谢谢你的耐心等待。

We are currently checking on this and will get back to you shortly, thank you for your patience.

谢谢,¥b $ b Syed Irfan Hussain

Thanks,
Syed Irfan Hussain


这篇关于Visual Studio Online REST API在使用OAuth进行身份验证时出现401 Unauthorized错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆