【发布时间】:2019-05-02 01:52:57
【问题描述】:
我有一个使用 Oauth 的 Web 应用程序,但由于以下错误而无法重用 authToken。
{"AADSTS70002: Error validating credentials. AADSTS54005: OAuth2 Authorization
code was already redeemed, please retry with a new valid code or use an
existing refresh token.\r\nTrace ID: 30c342a7-f16a-4a05-a4a8-
c7ee2c722300\r\nCorrelation ID: 3a5c99d1-ca1c-4cd7-bd36-
cce721bf05b6\r\nTimestamp: 2018-11-21 00:26:18Z"}
有人告诉我这是一个已知问题/更新 here 和 here。 ...好的,很好,所以现在我正在尝试获取刷新令牌,以便我可以重新生成我的访问令牌,但我无法让某些工作正常工作。
我已经尝试了以下方法: https://docs.microsoft.com/en-us/bingads/shopping-content/code-example-authentication-oauth - 当我尝试获取访问令牌或刷新令牌时,这个似乎不起作用并引发异常。说明发生了一个或多个错误。
https://auth0.com/docs/api/authentication#authorization-code-pkce- - 但不返回刷新令牌。这可能是因为我没有 code_verifier 吗?如果是这样,我将如何获得它?
Authorization Code (PKCE) Image
下面是我正在使用的代码示例 - 这里的问题是我只能使用一次,一旦它已被修复,我无法静默检索它,因为它不再存在于缓存中。
ClientCredential clientcred = new ClientCredential(Constants.ClientId, Constants.AppKey);
TokenCache TC = new TokenCache();
AuthenticationContext AC = new AuthenticationContext(Constants.Authority, TC);
//Set token from authentication result
AuthenticationResult authenticationResult = await AC.AcquireTokenByAuthorizationCodeAsync(
Constants.Code,
new Uri(Constants.postLogoutRedirectUri + "Index"), clientcred);
return authenticationResult.AccessToken;
【问题讨论】:
-
你连接的是什么认证服务器?
-
您找到解决方法了吗?我有同样的问题。
标签: c# oauth oauth-2.0 access-token