From 75984c4ff43a93b2d6bcab44952c65a6cdc4f95f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 31 Aug 2019 16:19:48 +0300 Subject: [PATCH] protonmail: fix /auth/refresh, remove Client{ID,Secret} ClientID and ClientSecret are no longer used. Closes: https://github.com/emersion/hydroxide/issues/68 --- cmd/hydroxide/hydroxide.go | 2 -- protonmail/auth.go | 13 ++----------- protonmail/protonmail.go | 3 --- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/cmd/hydroxide/hydroxide.go b/cmd/hydroxide/hydroxide.go index 4e1e3cf..35d51ff 100644 --- a/cmd/hydroxide/hydroxide.go +++ b/cmd/hydroxide/hydroxide.go @@ -30,8 +30,6 @@ func newClient() *protonmail.Client { return &protonmail.Client{ RootURL: "https://dev.protonmail.com/api", AppVersion: "Web_3.16.2", - ClientID: "Web", - ClientSecret: "4957cc9a2e0a2a49d02475c9d013478d", } } diff --git a/protonmail/auth.go b/protonmail/auth.go index 7bc6dcf..dbf1eaa 100644 --- a/protonmail/auth.go +++ b/protonmail/auth.go @@ -12,8 +12,6 @@ import ( ) type authInfoReq struct { - ClientID string - ClientSecret string Username string } @@ -53,8 +51,6 @@ func (resp *AuthInfoResp) authInfo() *AuthInfo { func (c *Client) AuthInfo(username string) (*AuthInfo, error) { reqData := &authInfoReq{ - ClientID: c.ClientID, - ClientSecret: c.ClientSecret, Username: username, } @@ -72,8 +68,6 @@ func (c *Client) AuthInfo(username string) (*AuthInfo, error) { } type authReq struct { - ClientID string - ClientSecret string Username string SRPSession string ClientEphemeral string @@ -126,8 +120,6 @@ func (c *Client) Auth(username, password, twoFactorCode string, info *AuthInfo) } reqData := &authReq{ - ClientID: c.ClientID, - ClientSecret: c.ClientSecret, Username: username, SRPSession: info.srpSession, ClientEphemeral: base64.StdEncoding.EncodeToString(proofs.clientEphemeral), @@ -153,7 +145,6 @@ func (c *Client) Auth(username, password, twoFactorCode string, info *AuthInfo) } type authRefreshReq struct { - ClientID string UID string `json:"Uid"` RefreshToken string @@ -161,14 +152,14 @@ type authRefreshReq struct { ResponseType string GrantType string RedirectURI string - State string } func (c *Client) AuthRefresh(expiredAuth *Auth) (*Auth, error) { reqData := &authRefreshReq{ - ClientID: c.ClientID, UID: expiredAuth.UID, RefreshToken: expiredAuth.RefreshToken, + ResponseType: "token", + GrantType: "refresh_token", } req, err := c.newJSONRequest(http.MethodPost, "/auth/refresh", reqData) diff --git a/protonmail/protonmail.go b/protonmail/protonmail.go index 9c12295..771e179 100644 --- a/protonmail/protonmail.go +++ b/protonmail/protonmail.go @@ -54,9 +54,6 @@ type Client struct { RootURL string AppVersion string - ClientID string - ClientSecret string - HTTPClient *http.Client ReAuth func() error