diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-01-12 21:32:40 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-01-12 21:34:00 +0100 |
| commit | 07b3361d998c9b653f39d382da04914abcb00296 (patch) | |
| tree | 763098e4a3eca886653c9315b62bff5b1952f78d /internal | |
| parent | b51831b6361dde4e63fa38bfd968ff729ab72dc5 (diff) | |
OAuth: Properly cache the Client ID
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/oauth/oauth.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index fd8a63d..924b434 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -75,6 +75,9 @@ func genVerifier() (string, error) { // OAuth defines the main structure for this package. type OAuth struct { + // The cached client id so we don't have to pass it around + ClientID string `json:"client_id"` + // The HTTP client that is used httpClient *httpw.Client @@ -274,7 +277,11 @@ func (oauth *OAuth) refreshResponse(r string) (*TokenResponse, time.Time, error) if oauth.token == nil { return nil, time.Time{}, errors.New("No oauth token structure in refresh") } + if oauth.ClientID == "" { + return nil, time.Time{}, errors.New("No client ID was cached for refresh") + } data := url.Values{ + "client_id": {oauth.ClientID}, "refresh_token": {r}, "grant_type": {"refresh_token"}, } @@ -435,6 +442,9 @@ func (oauth *OAuth) ListenerPort() (int, error) { // AuthURL gets the authorization url to start the OAuth procedure. func (oauth *OAuth) AuthURL(name string, postProcessAuth func(string) string) (string, error) { + // Update the client ID + oauth.ClientID = name + // Generate the verifier and challenge v, err := genVerifier() if err != nil { |
