简体   繁体   English

aws-amplify 内置方式重定向到 reactjs 应用程序中的 Microsoft 登录页面

[英]aws-amplify inbuilt way to redirect to Microsoft sign-in page in reactjs app

NOTE : I don't want to use inbuilt hostedUI page of AWS Cognito service .注意我不想使用 AWS Cognito 服务的内置 hostedUI 页面

I have my own custom login page with which I already integrated google and facebook login by providing two more buttons called Google Login Facebook Login .我有自己的自定义登录页面,我已经通过提供另外两个名为Google Login Facebook Login的按钮集成了googlefacebook登录。

When Google Login button is clicked, it opens directly (from my custom login page) google sign-in page with following code,单击Google Login按钮时,它会直接(从我的自定义登录页面)打开带有以下代码的 google 登录页面,

const googleLogin = async () => {

    Auth.federatedSignIn({ provider: CognitoHostedUIIdentityProvider.Google }).then(cred => {
      ...
    }).catch(e => {
      ...
    });

}

and same kind of implementation for facebook : provider: { provider: CognitoHostedUIIdentityProvider.Facebook} and it will redirect me to facebook login page.facebook的相同类型的实现: provider: { provider: CognitoHostedUIIdentityProvider.Facebook}它会将我重定向到 facebook 登录页面。

Now, I want to integrate Auzre-Ad login to my login page.现在,我想将Auzre-Ad login集成到我的登录页面。 So added one more button Microsoft Azure Login所以又添加了一个按钮Microsoft Azure Login

const microsofAzureLogin = async () => {

        Auth.federatedSignIn({ /* **What should I add here** */ }).then(cred => {
          ...
        }).catch(e => {
          ...
        });

}

What should I add in above code so when Microsoft Azure Login button is clicked, it redirects me to我应该在上面的代码中添加什么,以便当单击Microsoft Azure Login按钮时,它会将我重定向到

It should be the name, you have given in Cognito for Microsoft, as an OIDC provider.它应该是您在 Cognito for Microsoft 中作为 OIDC 提供商提供的名称。

Which is mentioned in this document , under identity_provider param.这是在本文档中提到的,在identity_provider参数下。

Add this parameter to bypass the hosted UI and redirect your user to a provider sign-in page.添加此参数以绕过托管 UI 并将您的用户重定向到提供商登录页面。 The value of the identity_provider parameter is the name of the identity provider (IdP) as it appears in your user pool. identity_provider 参数的值是身份提供者 (IdP) 的名称,因为它出现在您的用户池中。


    const azureLogin = () => {
        window.location.href = `https://${process.env.COGNITO_DOMAIN}/oauth2/authorize?
        identity_provider=${process.env.IDENTITY_PROVIDER_NAME}
        &redirect_uri=${process.env.COGNITO_REDIRECT_SIGNIN}
        &response_type=CODE
        &client_id=${process.env.COGNITO_APP_CLIENT_ID}
        &scope=${process.env.COGNITO_SCOPE}`;
      }

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

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