'Spring Boot with Oauth2

I developed a Google OAuth2 Login in Spring Boot and its working fine. I want to redirect to some specific URL after a button has been clicked. I am using an application.yml with Google Oauth2.

I want to redirect to a specific URL after my authentification.

Here is the code I use for Google OAuth2:

Application.yml

security:
  oauth2:
    client:
      clientId: <Google Client Id>
      clientSecret: <Google Secret Id>
      accessTokenUri: https://accounts.google.com/o/oauth2/token
      userAuthorizationUri: https://accounts.google.com/o/oauth2/v2/auth
      clientAuthenticationScheme: form
      scope:
        - openid
        - email
        - profile
    resource:
      userInfoUri: https://www.googleapis.com/oauth2/v3/userinfo
      preferTokenInfo: true 


Solution 1:[1]

In the authorize request towards Google, you should add the redirect_uri parameter

  security:
    oauth2:
      client:
        clientId: <Google Client Id>
        clientSecret: <Google Secret Id>
        redirectUri: https://YOUR_REDIRECT_URL // *** here ***
        accessTokenUri: https://accounts.google.com/o/oauth2/token
        userAuthorizationUri: https://accounts.google.com/o/oauth2/v2/auth
        clientAuthenticationScheme: form
        scope:
          - openid
          - email
          - profile
      resource:
        userInfoUri: https://www.googleapis.com/oauth2/v3/userinfo
        preferTokenInfo: true 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1