From db983eed89105b4d93f68cf9732fdcd4fe288b56 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 14 Nov 2019 09:12:34 +0100 Subject: [PATCH] protonmail: fix "invalid input" error on /auth/refresh It seems like we were just missing a valid RedirectURI. References: https://github.com/emersion/hydroxide/issues/70 --- auth/auth.go | 3 +-- protonmail/auth.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index f3744b6..bf6c568 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -112,8 +112,7 @@ func EncryptAndSave(auth *CachedAuth, username string, secretKey *[32]byte) erro func authenticate(c *protonmail.Client, cachedAuth *CachedAuth, username string) (openpgp.EntityList, error) { auth, err := c.AuthRefresh(&cachedAuth.Auth) - // TODO: error code 2000/2001 'invalid input' happens since 09.2019 - if apiErr, ok := err.(*protonmail.APIError); ok && (apiErr.Code == 10013 || apiErr.Code == 2000 || apiErr.Code == 2001) { + if apiErr, ok := err.(*protonmail.APIError); ok && apiErr.Code == 10013 { // Invalid refresh token, re-authenticate authInfo, err := c.AuthInfo(username) if err != nil { diff --git a/protonmail/auth.go b/protonmail/auth.go index dd09fe3..c241a39 100644 --- a/protonmail/auth.go +++ b/protonmail/auth.go @@ -163,6 +163,7 @@ func (c *Client) AuthRefresh(expiredAuth *Auth) (*Auth, error) { RefreshToken: expiredAuth.RefreshToken, ResponseType: "token", GrantType: "refresh_token", + RedirectURI: "http://www.protonmail.ch", } req, err := c.newJSONRequest(http.MethodPost, "/auth/refresh", reqData)