简体   繁体   中英

Spring boot oauth2 token

I have an ouath2 module, server running on port 9999, and when I request "localhost:9999/oauth/token" I do get the token. However, even the auth server and the REST endpoints are in the same project (different modules, but they know about each other), the controllers seem to not care if the request holds a token.

Now, here comes the interesting stuff:

If I add this code to my application.yml, the controllers do not care about the auth at all.

security:
  basic:
    enabled: false
  oauth2:
    client:
      client-id: acme
      client-secret: acmesecret
      access-token-uri: http://localhost:9999/oauth/token
      user-authorization-uri: http://localhost:9999/oauth/authorize
    resource:
      user-info-uri: http://localhost:9999/user
      token-info-uri: http://localhost:9999/oauth/check_token

auth:
 server:
  url: http://localhost:9999/oauth/check_token/
  clientId: acme
  clientSecret: acmesecret
oauth2:
 resource:
  userInfoUri: http://localhost:9999/user

But, when I remove it and try to request the controller I get this:

{
  "timestamp": 1472114046044,
  "status": 401,
  "error": "Unauthorized",
  "message": "Full authentication is required to access this resource",
  "path": "/gamification/api/ebubo"
}

Any ideas? Anyone?

@ComponentScan("the_actual_package")丢失

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