github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/actor/v2action/token.go (about) 1 package v2action 2 3 import ( 4 "strings" 5 6 "github.com/SermoDigital/jose/jws" 7 "github.com/SermoDigital/jose/jwt" 8 ) 9 10 func (actor Actor) RefreshAccessToken(refreshToken string) (string, error) { 11 tokens, err := actor.UAAClient.RefreshAccessToken(refreshToken) 12 if err != nil { 13 return "", err 14 } 15 16 actor.Config.SetAccessToken(tokens.AuthorizationToken()) 17 actor.Config.SetRefreshToken(tokens.RefreshToken) 18 19 return tokens.AuthorizationToken(), nil 20 } 21 22 func (actor Actor) ParseAccessToken(accessToken string) (jwt.JWT, error) { 23 tokenStr := strings.TrimPrefix(accessToken, "bearer ") 24 return jws.ParseJWT([]byte(tokenStr)) 25 }