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
This commit is contained in:
Simon Ser 2019-11-14 09:12:34 +01:00
parent d5a7cf4e0a
commit db983eed89
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 2 additions and 2 deletions

View File

@ -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) { func authenticate(c *protonmail.Client, cachedAuth *CachedAuth, username string) (openpgp.EntityList, error) {
auth, err := c.AuthRefresh(&cachedAuth.Auth) 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 {
if apiErr, ok := err.(*protonmail.APIError); ok && (apiErr.Code == 10013 || apiErr.Code == 2000 || apiErr.Code == 2001) {
// Invalid refresh token, re-authenticate // Invalid refresh token, re-authenticate
authInfo, err := c.AuthInfo(username) authInfo, err := c.AuthInfo(username)
if err != nil { if err != nil {

View File

@ -163,6 +163,7 @@ func (c *Client) AuthRefresh(expiredAuth *Auth) (*Auth, error) {
RefreshToken: expiredAuth.RefreshToken, RefreshToken: expiredAuth.RefreshToken,
ResponseType: "token", ResponseType: "token",
GrantType: "refresh_token", GrantType: "refresh_token",
RedirectURI: "http://www.protonmail.ch",
} }
req, err := c.newJSONRequest(http.MethodPost, "/auth/refresh", reqData) req, err := c.newJSONRequest(http.MethodPost, "/auth/refresh", reqData)