How to integrate react native application with spring boot oauth2

Viewed 735

I have spring boot application that has oauth2 configuration as you can see below:

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)

Now, i have a react-native application that uses google-signin plugin to signin with google. how can i integrate this react-native app to works with spring boot application in signin/signup?

As you can see in google-signin plugin, it doesn't have any callback or redirect url in options.

1 Answers

I solve this problem without using any plugin, just when user touched the google or facebook login, i redirected user to google or facebook, for example to https://localhost/oauth2/authorize/google?redirect_uri=https://localhost/oauth2/redirect.

After authorization completed i checked that user comes from mobile or not (using user agent info) and if it was true i redirected user to myapp://accessToken/{{token_value_from_google_or_facebook}}, with this redirection my mobile application opened and every thing is OK.

Related