无论我尝试什么配置,我总是得到:
我正在使用oauth2-vanilla中的示例:oauth2-vanilla example
但是我在尝试登录时遇到以下异常:
2016-11-19 21:26:06.187 DEBUG 2753 --- [nio-5000-exec-4] o.s.web.client.RestTemplate : Created POST request for "https://api.fablabs.io/oauth/token"
2016-11-19 21:26:06.187 DEBUG 2753 --- [nio-5000-exec-4] g.c.AuthorizationCodeAccessTokenProvider : Encoding and sending form: {grant_type=[authorization_code], code=[737a5cedc764e74ddcb75bf6833516fb6fba8c20ae568fd4936e2a616fe0c30c], redirect_uri=[http://localhost:5000/login], client_id=[62c5dd374d13a7ec6469641433e20648c9cab3f10a643c5f4f55b35f11cae307], client_secret=[b98fe2e6d9214674ab25e82c5065c9aa87d61d1bd6f35f9f6ddc44aeb60f2c95]}
2016-11-19 21:26:06.639 DEBUG 2753 --- [nio-5000-exec-4] o.s.web.client.RestTemplate : POST request for "https://api.fablabs.io/oauth/token" resulted in 403 (Forbidden); invoking error handler
2016-11-19 21:26:06.641 DEBUG 2753 --- [nio-5000-exec-4] o.s.b.a.audit.listener.AuditListener : AuditEvent [timestamp=Sat Nov 19 21:26:06 PET 2016, principal=UNKNOWN, type=AUTHENTICATION_FAILURE, data={type=org.springframework.security.authentication.BadCredentialsException, message=Could not obtain access token}]
2016-11-19 21:26:06.644 DEBUG 2753 --- [nio-5000-exec-4] uth2ClientAuthenticationProcessingFilter : Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Could not obtain access token
这是我的UI服务器的application.yml:
server:
port: 5000
tomcat:
remote_ip_header: x-forwarded-for
protocol_header: x-forwarded-proto
debug: true
spring:
aop:
proxy-target-class: true
security:
oauth2:
client:
accessTokenUri: https://api.fablabs.io/oauth/token
userAuthorizationUri: https://api.fablabs.io/oauth/authorize
clientId: 62c5dd374d13a7ec6469641433e20648c9cab3f10a643c5f4f55b35f11cae307
clientSecret: b98fe2e6d9214674ab25e82c5065c9aa87d61d1bd6f35f9f6ddc44aeb60f2c95
clientAuthenticationScheme: form
resource:
userInfoUri: https://api.fablabs.io/v0/me.json
zuul:
routes:
resource:
path: /resource/**
url: http://localhost:9000
user:
path: /user/**
url: https://api.fablabs.io/v0/me.json
logging:
level:
org.springframework.security: DEBUG
org.springframework.web: DEBUG
可能有什么不对?使用Auth服务器可能是cookie,https,CSRF的问题?我不知道如何验证这一点。请给我一些帮助。
显然OAuth2 provider对其他客户端没有问题,但是没有使用我的Java客户端。 我在使用Github和Google API Oauth2端点时成功获得了Access Token。那么,这里可能出现什么问题???