我使用 spring boot 教程作为基础 ( https://spring.io/guides/tutorials/spring-boot-oauth2/ ) 来测试 Oauth2。
但是,我的身份验证服务器不是 facebook,而是 Netiq Access Manager (NAM)。我设法被重定向到 NAM 登录页面,但登录后,我收到以下错误:
日志显示:
o.s.b.a.s.o.r.UserInfoTokenServices : Could not fetch user details: class org.springframework.web.client.HttpClientErrorException, 401 Unauthorized
这是项目:
应用程序代码:
package com.example.springoauthdemo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
@SpringBootApplication
@EnableOAuth2Sso
public class SocialApplication {
public static void main(String[] args) {
SpringApplication.run(SocialApplication.class, args);
}
}
应用程序.yml
security:
oauth2:
client:
clientId: 55bb61f1-4384-4939-9cd0-fa7d76af9a0c
clientSecret: fdUjegFlCJjnD778RUSuS4SqMRey4IKVDOkadi4hjN6YbhC1xCInxoxobf-a-p-po8rt1wfZM2BPqJHpcZ-FGs
accessTokenUri: https://nam.example.com/nidp/oauth/nam/token
userAuthorizationUri: https://nam.example.com/nidp/oauth/nam/authz
tokenName: oauth_token
authenticationScheme: query
clientAuthenticationScheme: form
resource:
userInfoUri: https://localhost:8443/index.html
#userInfoUri: https://nam.example.com/nidp/oauth/nam/userinfo
server:
port: 8443
ssl:
enabled: true
key-alias: tomcat-localhost
key-password: changeit
key-store: classpath:keystore.jks
key-store-provider: SUN
key-store-type: JKS
key-store-password: changeit
据我所知,以这个Oauth2 流程为例,步骤 1、2 和 3 似乎没问题,所以问题是试图获取访问令牌?
有任何想法吗?
提前致谢!