Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.springframework.security.core.context.SecurityContextHolder
- import org.springframework.security.oauth2.core.OAuth2AccessToken
- fun getCurrentUserToken(): String? {
- val authentication = SecurityContextHolder.getContext().authentication
- if (authentication != null && authentication.isAuthenticated) {
- val token = authentication.details as? OAuth2AccessToken
- return token?.tokenValue
- }
- return null
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement