Home » Java » java – OAuth2 spring security with google callback not working-Exceptionshub

java – OAuth2 spring security with google callback not working-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

i have developed the micro service application, in that application there is a service call user service which is running on port 8281. This service handle the authentications. when i test the service in local environment this is worked fine. But if i call this service using zuul api gateway this is not working. following property in the application.yml file is use to get the redirect url in the local environment. This is worked fine.

  security:
    oauth2:
      client:
        registration:
          google:
            redirectUri: "http://localhost:8281/oauth2/callback/google"

But if i change this property as follow for connect with zuul api gateway.

  security:
    oauth2:
      client:
        registration:
          google:
            redirectUri: "http://localhost:8080/api/user/oauth2/callback/google"

This is not working and is throw this error message [authorization_request_not_found]. localhost:8080 is the zuul api gateway. zuul has configure to forward request to user service like this.

zuul:
  prefix: /api
  routes:
    auth-service:
      path: /user/**
      serviceId: USER-SERVICE
      stripPrefix: true
      sensitiveHeaders: Cookie,Set-Cookie

so why this error is thrown ?

How to&Answers: