fon*_*lif 9 curl angularjs spring-boot spring-security-oauth2 jhipster
我正在尝试使用jhipster工具,以便使用oauth2身份验证创建一个新项目.项目示例工作正常,我可以使用angularjs接口登录,但无法理解如何创建新用户,然后通过Curl命令行为此新用户获取访问令牌.
谢谢你的帮助
Ror*_*mpf 10
步骤#1:注册用户.
在http:// localhost:8080 /#/ register注册用户,并确保您可以通过Web界面登录.
步骤2:获取OAuth2令牌.
获取OAuth2令牌所需的信息:
然后,从服务器获取OAuth 2令牌:
curl -X POST -vu client:secret http://localhost:8080/oauth/token -H "Accept: application/json" -d "username=username&password=password&grant_type=password&scope=read&client_id=clientid&client_secret=secret"
Run Code Online (Sandbox Code Playgroud)
..返回这样的东西:
{"access_token":"7916d326-0f7f-430f-8e32-c5135a121052","token_type":"bearer","refresh_token":"2c69ca58-a657-4780-b5d8-dc965d518e9e","expires_in":1037,"scope":"read"}
Run Code Online (Sandbox Code Playgroud)
步骤3:在对受保护资源的调用中使用令牌:
然后,每次调用时都必须在标头中提供auth令牌:
curl http://localhost:8080/app/rest/books -H "Authorization: Bearer 7916d326-0f7f-430f-8e32-c5135a121052"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5726 次 |
| 最近记录: |