简体   繁体   English

如何在Azure AD B2C中获取访问令牌而不是指向重定向URL

[英]How to get access token instead of pointing to redirect URL in Azure AD B2C

I've created a custom policy in my Azure AD B2C tenant from which I'm getting my user flow endpoint. 我在Azure AD B2C租户中创建了一个自定义策略,从中可以获取用户流终结点。 At this point I am able to log my registered user in and after a successful login attempt it redirects me to my redirect URL (which in my case is https://jwt.ms ) where my access token is decoded. 此时,我能够登录我的注册用户,并且在成功登录尝试后,它会将我重定向到我的重定向URL(在我的情况下是https://jwt.ms ),在此我的访问令牌被解码。

What I'm doing right now is opening the same user flow endpoint in a react native app using WebView . 我现在正在做的是使用WebView在react native应用程序中打开相同的用户流终结点。 It works perfectly but it then redirect to my redirect URL ( https://jwt.ms ) which I dont want. 它工作正常,但随后重定向到了我不需要的重定向URL( https://jwt.ms )。 What I want is to return me the access token which I can get after a successful login so I can use the token to get the user information by decoding it. 我想要的是将成功登录后可以获取的访问令牌返回给我,这样我就可以使用该令牌通过对其进行解码来获取用户信息。

How can I get access token instead of my app pointing to redirect URL? 如何获取访问令牌而不是我的应用程序指向重定向URL?

I was digging for a solution and found this library. 我正在寻找解决方案,并找到了这个库。 This library takes your existing AADB2C tenant and returns you the access token. 该库将使用您现有的AADB2C租户,并向您返回访问令牌。

Note you might want to edit onNavigationStateChange function in LoginView.js to close the webview and redirect your app to a specific screen after login. 请注意,您可能要在LoginView.js编辑onNavigationStateChange函数以关闭onNavigationStateChange ,并在登录后将您的应用重定向到特定屏幕。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM