Advertisement
SimpleCookie

Untitled

Feb 13th, 2024
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.44 KB | None | 0 0
  1. import org.springframework.security.core.context.SecurityContextHolder
  2. import org.springframework.security.oauth2.core.OAuth2AccessToken
  3.  
  4. fun getCurrentUserToken(): String? {
  5.     val authentication = SecurityContextHolder.getContext().authentication
  6.     if (authentication != null && authentication.isAuthenticated) {
  7.         val token = authentication.details as? OAuth2AccessToken
  8.         return token?.tokenValue
  9.     }
  10.     return null
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement