Spring Oauth2授权+ JWT以编程方式生成令牌

时间:2018-09-27 21:11:54

标签: spring-boot oauth-2.0 jwt token spring-security-oauth2

我已经使用Spring Oauth2创建了Spring Boot(2.0.5)应用程序。

具体地说,我已经使用@EnableAuthorizationServerin this tutorial所述的配置启用了授权服务器。

我已验证OAuth2服务器正在使用curl等功能

curl myclientid:secret@localhost:8080/oauth/token -d "grant_type=password&username=user&password=password" | jq

我得到一个有效的响应(在这里被截断了):

{
  "access_token":  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxx.yyy",
  "token_type": "bearer",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxx.yyy",
  "expires_in": 43199,
  "scope": "read write",
  "jti": "003c6e7a-6e32-4d19-8773-bf739de13c69"
}

我的问题是如何以编程方式创建 authorization_code 令牌?

具体来说,我需要在代码中添加一个自定义流(用于魔术链接),就像用户直接调用端点/oauth/authorize?response_type=code一样。

该代码需要生成带有授权代码的令牌,例如代码= 123,可用于随后的/oauth/tokengrant_type=authorization_code&code=123的POST请求中

0 个答案:

没有答案
相关问题