大佬教程收集整理的这篇文章主要介绍了活动目录 xamarin 表单中的无效令牌,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 Xamarin 表单开发一个小型应用程序,我想实现 (MSAL) 活动目录,我已经配置了所有内容并获取了令牌,之后我在到达下方时检查了邮递员 {"success": false," message": "抱歉,您无权访问此 API。请确保您已登录!","data":null}
PASS examples/68419899/methods.test.ts (8.659 s)
68419899
✓ should pass (5 ms)
------------|---------|----------|---------|---------|-------------------
file | % Stmts | % Branch | % Funcs | % lines | Uncovered line #s
------------|---------|----------|---------|---------|-------------------
All files | 81.82 | 100 | 66.67 | 75 |
methods.ts | 88.89 | 100 | 80 | 83.33 | 10
utils.ts | 50 | 100 | 0 | 50 | 2
------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed,1 @R_649_10586@l
Tests: 1 passed,1 @R_649_10586@l
Snapshots: 0 @R_649_10586@l
Time: 9.198 s
@H_235_2@mainactivity.cs
App.parentwindow = this;
protected overrIDe voID OnActivityResult(int requestCode,Result resultCode,Intent data)
{
base.onActivityResult(requestCode,resultCode,data);
AuthenticationConTinuationHelper.SetAuthenticationConTinuationEventArgs(requestCode,data);
}
I trIEd sending the web request to server while I am getTing http response below
{StatusCode: 401,ReasonPhrase: 'Unauthorized',Version: 1.1,Content: System.Net.http.httpconnection+httpconnectionResponseContent,headers: { transfer-encoding: chunked Server: Kestrel WWW-Authenticate: Bearer error="invalID_token",error_description="The signature is invalID" X-Rate-limit-limit: 12h X-Rate-limit-Remaining: 4999 X-Rate-limit-reset: 2021-07-19T14:20:05.8546118Z Date: Mon,19 Jul 2021 02:20:05 GMT Content-Type: text/plain }}
Here I trIEd the code below,please Help me to resolve this issue
App.xaml.cs
public static IPublicclIEntApplication PCA = null;
public static String[] Scopes = { "User.Read" };
PCA = PublicclIEntApplicationBuilder.Create(Constants.CLIENtID)
.WithRedirectUri($"msauth://{Constants.AppID}/{Constants.SIGNATURE_HASH}")
.WithAuthority($"https://login.microsoftonline.com/{Constants.TenentID}")
.build();
viewmodel signin command i called SignInAsync
public async Task SignInAsync()
{
Microsoft.IDentity.ClIEnt.AuthenticationResult authResult = null;
IEnumerable<IAccount> accounts = await App.pCA.GetAccountsAsync().ConfigureAwait(false);
try
{
IAccount firstAccount = accounts.FirstOrDefault();
authResult = await App.pCA.AcquiretokenSilent(App.Scopes,firstAccount)
.ExecuteAsync();
Session.Instance.TokenValueFromApp = authResult.Accesstoken;
}
catch (MsalUirequiredException)
{
try
{
authResult = await App.pCA.AcquiretokenInteractive(App.Scopes) .WithParentActivityOrWindow(App.parentwindow)
.ExecuteAsync();
Session.Instance.TokenValueFromApp = authResult.Accesstoken;
}
catch (Exception ex2)
{
}
}
}
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的活动目录 xamarin 表单中的无效令牌全部内容,希望文章能够帮你解决活动目录 xamarin 表单中的无效令牌所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。