【问题标题】:@aws-amplify/auth federatedSignUp function?@aws-amplify/auth federatedSignUp 功能?
【发布时间】:2020-11-18 10:22:32
【问题描述】:

通过npm包@aws-amplify/auth使用react(import Auth from '@aws-amplify/auth'),有一些导出的函数如Auth.signUp({...})Auth.federatedSignIn()federatedSignIn 将用户发送到路径为 /login 的联合登录端点。我想将它们发送到/signup 路径但没有这样的federatedSignUp() 函数,有人知道将它们发送到/signup 联合端点的解决方案吗?

【问题讨论】:

    标签: reactjs amazon-cognito aws-amplify


    【解决方案1】:

    我的解决方案是将用户重定向到以下 URL:

    https://${COGNITO_OAUTH_DOMAIN}/signup?response_type=code&client_id=${CLIENT_ID}&redirect_uri=${encodeURIComponent(COGNITO_OAUTH_REDIRECT_SIGN_IN_URL)}
    

    【讨论】:

    • 看起来是一个可靠的答案,所以我会这样做,我考虑过但不知道我需要在 url 中输入的范围,感谢您澄清这一点
    【解决方案2】:

    使用@jellycsc 的解决方案并对其进行扩展(因为我未经授权)这是有效的(我建议其他人去他们的注册网址并手动复制它并系统地替换值)。

    const baseUrl = `https://${aws.idpDomain}/signup`
    const search = `?response_type=token&client_id=${aws.userPoolWebClientId}&redirect_uri=${encodeURIComponent(
        aws.redirectSignIn
      )}&identity_provider=COGNITO&scope=email%20openid%20profile`
    
    window.location.replace(baseUrl + search)
    

    【讨论】:

      猜你喜欢
      • 2022-07-30
      • 2020-10-14
      • 2019-12-25
      • 2021-11-16
      • 2023-02-03
      • 2021-10-29
      • 2023-03-22
      • 1970-01-01
      • 2019-06-29
      相关资源
      最近更新 更多