feat: add rp.RefreshAccessToken (#198)
* chore: make tokenEndpointCaller public * add RelyingParty function * undo changes made by gofumpt * undo more gofumpt changes * undo more gofumpt changes
This commit is contained in:
parent
0b4d62c745
commit
94871afbcb
3 changed files with 25 additions and 5 deletions
|
@ -536,3 +536,23 @@ func WithClientAssertionJWT(clientAssertion string) CodeExchangeOpt {
|
|||
return client.ClientAssertionCodeOptions(clientAssertion)
|
||||
}
|
||||
}
|
||||
|
||||
type tokenEndpointCaller struct {
|
||||
RelyingParty
|
||||
}
|
||||
|
||||
func (t tokenEndpointCaller) TokenEndpoint() string {
|
||||
return t.OAuthConfig().Endpoint.TokenURL
|
||||
}
|
||||
|
||||
func RefreshAccessToken(rp RelyingParty, refreshToken, clientAssertion, clientAssertionType string) (*oauth2.Token, error) {
|
||||
request := oidc.RefreshTokenRequest{
|
||||
RefreshToken: refreshToken,
|
||||
Scopes: rp.OAuthConfig().Scopes,
|
||||
ClientID: rp.OAuthConfig().ClientID,
|
||||
ClientSecret: rp.OAuthConfig().ClientSecret,
|
||||
ClientAssertion: clientAssertion,
|
||||
ClientAssertionType: clientAssertionType,
|
||||
}
|
||||
return client.CallTokenEndpoint(request, tokenEndpointCaller{RelyingParty: rp})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue