Unable to get EnableOauth2Sso Working -- BadCredentialsException: Could not obtain access token Unable to get EnableOauth2Sso Working -- BadCredentialsException: Could not obtain access token spring spring

Unable to get EnableOauth2Sso Working -- BadCredentialsException: Could not obtain access token


Creating a Client Application :The context path has to be explicit if you are running both the client and the auth server on localhost, otherwise the cookie paths clash and the two apps cannot agree on a session identifier.

src : https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_authserver


Centinul as you've figured out this happens due to a cookie conflict, unfortunately cookies don't respect the port numbers. And so both Apps interfere with each other since both are setting JSESSIONID.

There are two easy workarounds:

  1. use server.context-path to move each App to different paths, note that you need to do this for both
  2. set the server.session.cookie.name for one App to something different, e.g., APPSESSIONID

I would suggest to put this workaround in a profile that you activate for localhost only.