如何将React Native应用程序与Spring Boot Oauth2集成

拉索尔·加法里(Rasool Ghafari)

我有一个具有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插件中看到的那样,它在选项中没有任何回调或重定向网址。

拉索尔·加法里(Rasool Ghafari)

我无需使用任何插件即可解决此问题,仅当用户触摸google或facebook登录名时,我便将用户重定向到google或facebook,例如https://localhost/oauth2/authorize/google?redirect_uri=https://localhost/oauth2/redirect

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何将Keycloak 7与Spring Boot 2集成

如何仅为 Spring Boot Security OAuth2 应用程序中的某些类启用 OAuth2?

将liquibase与Spring Boot 2集成时出错

如何将Angular 2与Spring Boot应用程序连接?

如何使用jar包装将React Webapp集成到Spring Boot应用程序内部

spring boot 应用程序将 kafka 与活动 mq 集成

如何对Spring Boot应用程序进行集成测试?

如何使用Spring Security 5在Spring Boot应用程序(而非Web应用程序)中获取oauth2访问令牌

将Spring Boot后端+ oauth与前端应用程序集成的问题

如何将 Angular 4 与现有的基于 Spring Boot jsp 的 Web 应用程序集成?

如何模拟测试Kotlin Spring Boot 2应用程序

将Play 2框架与现有Spring MVC应用程序3.1集成

如何将OmniFaces与Spring Boot集成

如何将Spring Boot与Spotify OAuth 2身份验证集成

将Spring Boot与现有的Spring应用程序集成

如何将振幅分析与React应用程序集成?

如何dockerize Spring Boot应用程序?

wso2 集成 Spring Boot 应用程序

如何在使用AWS ElasticBeanstalk和Nginx上的OAuth2的Spring Boot应用程序上强制使用SSL?

如何在我们的 Spring Boot oauth2 Web 应用程序中使用带有 google api 的组织域?

如何在Spring Boot应用程序中配置Embedded MongDB以进行集成测试?

如何在运行集成测试之前启动spring-boot应用程序

使用Keycloak的Spring Boot应用程序的Oauth2登录失败

如何从另一个Spring Boot应用程序访问一个Spring Boot应用程序的内存h2数据库

Spring Boot应用程序与Spring Cloud的集成测试

如何将Spring Boot应用程序项目部署到Heroku

如何将记录器注入示例Spring Boot应用程序的字段中?

如何将spring-boot作为客户端应用程序运行?

如何将Spring Boot应用程序大战部署到AWS Elastic Beanstalk?