简体   繁体   中英

Spring oauth2 sso example doesn't work

I am trying to repeat actions described in the official tutorial(Spring Boot and OAuth2)

I stuck on the section Hosting an Authorization Server

I tried to download all sources from github but result the same

I am trying to start sub project social-auth-server :

I found 2 starters there:

src\\main\\java\\com\\example\\SocialApplication.java - oauth2 server src\\test\\java\\com\\example\\ClientApplication.java - oauth2 client

quote from the tutorial:

Note that the server.context-path is set explicitly, so if you run the app to test it remember the home page is http://localhost:9999/client . Clicking on that link should take you to the auth server and once you you have authenticated with the social provider of your choice you will be redirected back to the client app

1.I've started both applications
2. In browser I type localhost:9999/client
3. As a result of previous step - browser redirects me to the localhost:8080
4. I click Login via Facebook
5. As a result of previous step - browser redirects me to the Facebook to input credentials.
6. I typed correct credentials
7. As a result of previous step - browser redirects me to the localhost:8080 . Even without my name on this page.

I expected that the browser would redirect me to the localhost:9999 and show me message Hello Nikolay!

Can you please help me with this tutorial?

You are using application.yml as defined in the tutorial . That Facebook app is registered with localhost:8080 url. It is specified in that tutorial itself.

The configuration refers to a client app registered with Facebook in their developers site, in which you have to supply a registered redirect (home page) for the app. This one is registered to "localhost:8080" so it only works in an app running on that address.

Try to create your own facebook app with redirect URL as localhost:9999 in configuration. Add your app's configuration in application.yml

OAuth Auth server will always try to redirect tokens to configured redirect url

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM