【问题标题】:Authorization in Azure AD B2C for the react React Native app在 Azure AD B2C 中对 React React Native 应用程序进行授权
【发布时间】:2019-10-28 13:35:40
【问题描述】:

有没有人成功地在 Azure Ad B2C 中创建具有授权的 React Native 应用程序?

我是为 React Web 应用程序和 .Net Core API 做的,但是我为 React Native 找到的任何库都不能正常工作,而且我是 React Native 的初学者。请给我一些提示教程或回购。我被困得太厉害了。

【问题讨论】:

    标签: azure react-native azure-active-directory react-native-android azure-ad-b2c


    【解决方案1】:

    我找到了一个适用于 Azure AD B2C 的 React-Native 库。你可以关注this article。 示例如下:

    import B2CAuthentication from "../auth-ad-js/ReactNativeADB2C";
    import LoginView from "../auth-ad-js/LoginView";
    
    const CLIENT_ID = "<provide your client id>";
    
    export default class LoginScreen extends React.Component {
      static navigationOptions = {
        title: "Login"
      };
    
      render() {
        const b2cLogin = new B2CAuthentication({
          tenant: 'yourtenant.onmicrosoft.com',
          client_id: CLIENT_ID,
          client_secret: "<key set in application/key>",
          user_flow_policy: "B2C_1_signupsignin",
          reset_password_policy: 'B2C_1_password_reset',
          token_uri: "https://saroujetmp.b2clogin.com/saroujetmp.onmicrosoft.com/oauth2/v2.0/token",
          authority_host: "https://saroujetmp.b2clogin.com/saroujetmp.onmicrosoft.com/oauth2/v2.0/authorize",
          redirect_uri: "https://functionapp120190131041619.azurewebsites.net/.auth/login/aad/callback",
          prompt: "login",
          scope: ["https://saroujetmp.onmicrosoft.com/api/offline_access", "offline_access"]
        });
    
        return (
          <LoginView
            context={b2cLogin}
            onSuccess={this.onLoginSuccess.bind(this)}
          />
        );
      }
      onLoginSuccess(credentials) {
        console.log("onLoginSuccess");
        console.log(credentials);
        // use credentials.access_token..
      }
    }
    

    【讨论】:

    • 是的,我也发现了,但可能做错了什么。你能描述一下你为实现这一目标所做的步骤吗?
    • 我的case真的很简单,我没有使用azure函数。我只是在寻找使用 ADB2C 进行原生反应的简单 oauth 方法
    • 你说的repo里面没有说明,怎么用?
    猜你喜欢
    • 2021-01-04
    • 1970-01-01
    • 2017-04-20
    • 2022-10-04
    • 2017-01-04
    • 2022-07-17
    • 2022-10-13
    • 1970-01-01
    • 2020-06-01
    相关资源
    最近更新 更多