Skip to content

Latest commit

 

History

History

hiauth-server

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

参考demo

https://blog.csdn.net/baidu_28068985/article/details/128431612

测试

启动 auh、client、resource服务后,访问:http://127.0.0.1:8081/hello 账号:test\test

http://127.0.0.1:8080/oauth2/authorize?client_id=demo-client-id&response_type=code&scope=user_info&redirect_uri=http://www.baidu.com

在跳转的url中能够去到code,接下来可以使用这个code换取accessToken

>curl --location --request POST 'http://127.0.0.1:8080/oauth2/token?grant_type=authorization_code&code=code&redirect_uri=http://www.baidu.com' --header 'Authorization: Basic ZGVtby1jbGllbnQtaWQ6ZGVtby1jbGllbnQtc2VjcmV0'
  • refresh_token
>curl --location --request POST 'http://127.0.0.1:8080/oauth2/token?grant_type=refresh_token&refresh_token=refresh_token' --header 'Authorization: Basic ZGVtby1jbGllbnQtaWQ6ZGVtby1jbGllbnQtc2VjcmV0' 
  • client_credentials
>curl --location --request POST 'http://127.0.0.1:8080/oauth2/token?grant_type=client_credentials&scope=user_info' --header 'Authorization: Basic ZGVtby1jbGllbnQtaWQ6ZGVtby1jbGllbnQtc2VjcmV0'
  • 访问resource服务接口
>curl --location --request POST 'http://127.0.0.1:8082/user/info' --header 'Authorization: Bearer token' 

curl --location --request GET 'http://127.0.0.1:8080/oauth2/authorize?client_id=demo-client-id&client_secret=demo-client-secret&response_type=code&redirect_uri=http://127.0.0.1:8081/login/oauth2/code/client-id-1'