PostMan 调用 Auth2.0 获取Token 报错问题总结

(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”)

  1. 调用放回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 等功能

在这里插入图片描述

刷新token

在这里插入图片描述

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值