xamarin表单具有Office 365身份验证 身份验证正常,但最近我收到此错误消息:
AADSTS54005:OAuth2授权代码已被兑换,请重试新的有效代码或使用现有的刷新令牌。
通过一些研究,我发现我需要刷新令牌。 ->
https://support.workspace365.net/hc/en-us/articles/360010259114--RESOLVED-Technical-issue-Workspace-365 问题是如何刷新令牌,任何人都可以指导我。
谢谢
这是我的代码:
public async Task<AuthenticationResult> Authenticate(string authority, string resource, string clientId, string returnUri)
{
AuthenticationResult authResult = null;
try
{
var authContext = new AuthenticationContext(authority);
if (authContext.TokenCache.ReadItems().Any())
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
var uri = new Uri(returnUri);
PlatformParameters platformParams = null;
android
platformParams = new PlatformParameters((Android.App.Activity)Forms.Context);
ios
Device.BeginInvokeOnMainThread(() =>
{
UIViewController controller = new UIViewController();
controller = UIApplication.SharedApplication.KeyWindow.RootViewController;
platformParams = new PlatformParameters(controller);
});
UserDialogs.Instance.HideLoading();
Authresult需要返回令牌,以便我可以从Office 365身份验证中使用它,但相反,我收到消息AADSTS54005:OAuth2授权...
authResult = await authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
authContext.TokenCache.Clear();
}
catch (Exception e)
{
Console.WriteLine("Execption : " + e.Message);
}
return authResult;
}
任何帮助将不胜感激,谢谢