(1) authorization_code:授权码 模式 (常用、安全行最好)
根据授权码获取accessToken
http://localhost:8080/oauth/token?code=6s9qUj&grant_type=authorization_code&redirect_uri=http://www.mayikt.com/callback&scope=all
报错类型
(1) invalid grant_type pwssword
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
// appid
.withClient("mayikt")
// appsecret
.secret(passwordEncoder.encode("123456"))
// 授权码
.authorizedGrantTypes("refresh_token","authorization_code","password","client_credentials")
// 作用域
.scopes("all")
// 资源的id
.resourceIds("mayikt_resource")
// 回调地址
.redirectUris("http://www.mayikt.com/callback");
authorizedGrantTypes(“refresh_token”,“authorization_code”,“password”,“client_credentials”)
- 调用放回401 , 需要在head 中添加baseAuth ,账号、密码为client 的账号密码
报错原因:没有baseAuth
(2)password:密码模式、 (安全性第二、交互次数少、可以使用)
(3)implicit:简化模式,不推荐使用、不安全,
需要用户登录、,不需要baseAuth 认证
http://localhost:8090/auth/oauth/authorize?client_id=ssoj-pc&response_type=token
直接返回回调地址和token
https://www.baidu.com/#access_token=ed1a5376-2459-4009-b9a4-84ce533da48e&token_type=bearer&expires_in=42526&scope=all
(4)client_credentials :客户端模式
适合系统内部模块间交互,直接以项目(client) 为主体, 不涉及用户认证及权限, 适合ssoLogin 等功能