简体   繁体   English

Spring Security:如何在请求标头中传递oauth2访问令牌

[英]Spring Security: How to pass oauth2 access token in request headers

On successful login to my spring security application configured with Oauth2, I received a response with Oauth2 token. 成功登录到使用Oauth2配置的spring安全应用程序后,我收到了一个带有Oauth2令牌的响应。

For the subsequent request I passed Oauth2 access_token in URI Query Parameter like this 对于后续请求,我在URI查询参数中传递了Oauth2 access_token ,如下所示

http://localhost:8090/myapplication/users/user?access_token=4c520795-eb07-4c2d-a91b-474c85fb481e

It is working fine. 它工作正常。

But instead of passing token in URI to make it more secure I wanted to send token in request headers.How to do this? 但是,不是在URI中传递令牌以使其更安全,我想在请求头中发送令牌。如何做到这一点?

Use the usual HTTP Authorization header: 使用通常的HTTP Authorization标头:

Authorization: Bearer <your-token-here>

For example 例如

Authorization: Bearer 4c520795-eb07-4c2d-a91b-474c85fb481e

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Security OAuth2-验证访问令牌 - Spring security OAuth2 - verify access token Spring Security OAuth2-如何禁用访问令牌到期? - Spring security OAuth2 - how to disable access token expiry? 在Spring Security OAuth2中使用用户名密码授予中的刷新令牌请求新的访问令牌 - Request new access token using refresh token in username-password grant in Spring Security OAuth2 带有oAuth2 / oAuth / Token请求405方法的Spring Security不允许 - Spring Security with oAuth2 /oAuth/Token request 405 method not allow 使用Spring Security OAuth2的JWT承载交换访问令牌请求 - JWT bearer exchange for access token request using Spring Security OAuth2 如何在Spring OAuth2中获取访问令牌 - How to get access token in spring oauth2 如何在spring security oauth2中分离访问令牌和刷新令牌端点 - How to separate access token and refresh token endpoint in spring security oauth2 如何使用Spring Boot / Spring Security包装对OAuth2承载令牌请求的调用? - How to use Spring Boot/Spring Security to wrap a call to an OAuth2 bearer token request? Spring OAuth2 为每个请求生成访问令牌到令牌端点 - Spring OAuth2 Generate Access Token per request to the Token Endpoint Spring Security OAuth2 何时检查访问令牌过期? - When does Spring Security OAuth2 check access token expiration?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM