oauth - "could not obtain access token" error in spring security oauth2 -


in spring project have oauth2 client app running on localhost:9999 , oauth2 authorization server running on localhost:8080. in result, after approval page, see error page don't know problem? when press f12 see set-cookie done! /oauth/token not called! , /me not called! , browser not redirect localhost:9999.

my client app

package sso.client; import java.security.principal; import org.springframework.boot.autoconfigure.enableautoconfiguration; import org.springframework.boot.autoconfigure.security.oauth2.client.enableoauth2sso; import org.springframework.boot.builder.springapplicationbuilder; import org.springframework.context.annotation.configuration; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.restcontroller;  @enableautoconfiguration @configuration @enableoauth2sso @restcontroller public class app {    @requestmapping("/")   public string home(principal user) {     return "hello " + user.getname();   }    public static void main(string[] args) {     new springapplicationbuilder(app.class)         .properties("spring.config.name=client").run(args);   }  } 

client.yml

server:   port: 9999 security:   oauth2:     client:       client-id: acme       client-secret: acmesecret       access-token-uri: http://localhost:8080/oauth/token       user-authorization-uri: http://localhost:8080/oauth/authorize     resource:       user-info-uri: http://localhost:8080/me 

my authorization server

package sso.raymon;  import java.security.principal;  import org.springframework.beans.factory.annotation.autowired; import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.enableautoconfiguration; import org.springframework.context.annotation.configuration; import org.springframework.security.authentication.authenticationmanager; import org.springframework.security.config.annotation.web.builders.httpsecurity; import org.springframework.security.config.annotation.web.configuration.enablewebsecurity; import org.springframework.security.config.annotation.web.configuration.websecurityconfigureradapter; import org.springframework.security.oauth2.config.annotation.configurers.clientdetailsserviceconfigurer; import org.springframework.security.oauth2.config.annotation.web.configuration.authorizationserverconfigureradapter; import org.springframework.security.oauth2.config.annotation.web.configuration.enableauthorizationserver; import org.springframework.security.oauth2.config.annotation.web.configuration.enableresourceserver; import org.springframework.security.oauth2.config.annotation.web.configuration.resourceserverconfigureradapter; import org.springframework.security.oauth2.config.annotation.web.configurers.authorizationserverendpointsconfigurer; import org.springframework.security.oauth2.config.annotation.web.configurers.authorizationserversecurityconfigurer; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.restcontroller;  @configuration @enableautoconfiguration @restcontroller @enablewebsecurity public class app extends websecurityconfigureradapter {      public static void main(string[] args) {           springapplication.run(app.class, args);      }       @configuration      @enableauthorizationserver      protected static class oauth2config extends authorizationserverconfigureradapter{            @autowired           private authenticationmanager authenticationmanager;             @override           public void configure(authorizationserverendpointsconfigurer endpoints) throws exception {                endpoints.authenticationmanager(authenticationmanager);           }            @override             public void configure(authorizationserversecurityconfigurer security)                     throws exception {                 // todo auto-generated method stub                 security.allowformauthenticationforclients();             }            @override           public void configure(clientdetailsserviceconfigurer clients) throws exception {                // @formatter:off                clients.inmemory()                .withclient("acme")                .authorizedgranttypes("authorization_code")                .authorities("role_client")                .scopes("read", "write")                .secret("acmesecret");                // @formatter:on           }       }      @requestmapping("/me")       public string home(principal user) {           return user.getname();      }       @configuration      @enableresourceserver       protected static class resourceserver extends resourceserverconfigureradapter {            @override            public void configure(httpsecurity http) throws exception {               http                     .antmatcher("/me")                     .authorizerequests().anyrequest().authenticated();           }       } } 

application.properties

security.user.name=forough security.user.password=m123 

error in blow url:

localhost:9999/login?code=xzgywz&state=27xzvy

error:

whitelable error page application has no explicit mapping /error, seeing fallback. there unexpected erroe (type=unauthorized, atatus=401). authentication failed: not obtain access token


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -