【问题标题】:How to integrate react native application with spring boot oauth2如何将 React Native 应用程序与 Spring Boot oauth2 集成
【发布时间】:2020-09-18 16:53:21
【问题描述】:

我有一个具有 oauth2 配置的 Spring Boot 应用程序,如下所示:

spring:
  security:
    oauth2:
      client:
        registration:
          google:
            clientId: clientIdValue
            clientSecret: clientSecretValue
            redirectUri: "https://localhost/oauth2/callback/{registrationId}"
            scope:
              - email
              - profile
          facebook:
            clientId: clientIdValue
            clientSecret: clientSecretValue
            redirectUri: "https://localhost/oauth2/callback/{registrationId}"
            scope:
              - email
              - public_profile
        provider:
          facebook:
            authorizationUri: https://www.facebook.com/v3.0/dialog/oauth
            tokenUri: https://graph.facebook.com/v3.0/oauth/access_token
            userInfoUri: https://graph.facebook.com/v3.0/me?fields=id,first_name,middle_name,last_name,name,email,verified,is_verified,picture.width(250).height(250)

现在,我有一个 react-native 应用程序,它使用 google-signin 插件通过 google 登录。如何将此 react-native 应用程序集成到登录/注册中的 Spring Boot 应用程序?

正如您在google-signin 插件中看到的那样,它在选项中没有任何回调或重定向 url。

【问题讨论】:

  • 是的,我回答了我的问题。

标签: reactjs spring-boot react-native oauth-2.0


【解决方案1】:

我在不使用任何插件的情况下解决了这个问题,就在用户触摸 google 或 facebook 登录时,我将用户重定向到 google 或 facebook,例如 https://localhost/oauth2/authorize/google?redirect_uri=https://localhost/oauth2/redirect

授权完成后,我检查了用户是否来自移动设备(使用用户代理信息),如果是,我将用户重定向到myapp://accessToken/{{token_value_from_google_or_facebook}},通过此重定向,我的移动应用程序打开,一切正常。

【讨论】:

    猜你喜欢
    • 2016-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 2020-12-08
    • 2021-10-15
    相关资源
    最近更新 更多