From 88a98c03ea22995619eb7e57ac9f58ea4fe16791 Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Thu, 29 Sep 2022 22:28:31 -0700 Subject: [PATCH] fix: rp.RefreshAccessToken did not work (#216) * oidc.RefreshTokenRequest cannot be used to in a request to refresh tokens because it does not explicitly include grant_types. * fix merge issue * undo accidental formatting changes --- pkg/client/rp/relying_party.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/client/rp/relying_party.go b/pkg/client/rp/relying_party.go index 9245c8c..af202a3 100644 --- a/pkg/client/rp/relying_party.go +++ b/pkg/client/rp/relying_party.go @@ -547,14 +547,25 @@ func (t tokenEndpointCaller) TokenEndpoint() string { return t.OAuthConfig().Endpoint.TokenURL } +type RefreshTokenRequest struct { + RefreshToken string `schema:"refresh_token"` + Scopes oidc.SpaceDelimitedArray `schema:"scope"` + ClientID string `schema:"client_id"` + ClientSecret string `schema:"client_secret"` + ClientAssertion string `schema:"client_assertion"` + ClientAssertionType string `schema:"client_assertion_type"` + GrantType oidc.GrantType `schema:"grant_type"` +} + func RefreshAccessToken(rp RelyingParty, refreshToken, clientAssertion, clientAssertionType string) (*oauth2.Token, error) { - request := oidc.RefreshTokenRequest{ + request := RefreshTokenRequest{ RefreshToken: refreshToken, Scopes: rp.OAuthConfig().Scopes, ClientID: rp.OAuthConfig().ClientID, ClientSecret: rp.OAuthConfig().ClientSecret, ClientAssertion: clientAssertion, ClientAssertionType: clientAssertionType, + GrantType: oidc.GrantTypeRefreshToken, } return client.CallTokenEndpoint(request, tokenEndpointCaller{RelyingParty: rp}) }