forked from Mirrors/oauth2
Support using ID token as the ouath access token.
This commit is contained in:
parent
8baca543ee
commit
339f3641d9
|
@ -69,6 +69,9 @@ type Config struct {
|
|||
|
||||
// PrivateClaims optionally specifies private claims in the JWT.
|
||||
PrivateClaims map[string]interface{}
|
||||
|
||||
// UseIDToken optionally uses ID token instead of access token.
|
||||
UseIDToken bool
|
||||
}
|
||||
|
||||
// TokenSource returns a JWT TokenSource using the configuration
|
||||
|
@ -168,6 +171,9 @@ func (js jwtSource) Token() (*oauth2.Token, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("oauth2: error decoding JWT token: %v", err)
|
||||
}
|
||||
if js.conf.UseIDToken {
|
||||
token.AccessToken = tokenRes.IDToken
|
||||
}
|
||||
token.Expiry = time.Unix(claimSet.Exp, 0)
|
||||
}
|
||||
return token, nil
|
||||
|
|
Loading…
Reference in New Issue