diff --git a/client.go b/client.go index cae1aaa..c7cf804 100644 --- a/client.go +++ b/client.go @@ -178,7 +178,7 @@ func (c *Client) authRefresh(ctx context.Context) error { c.hookLock.RLock() defer c.hookLock.RUnlock() - auth, err := c.m.authRefresh(ctx, c.uid, c.ref) + auth, err := c.m.authRefresh(ctx, c.uid, c.ref, c.acc) if err != nil { if respErr, ok := err.(*resty.ResponseError); ok { diff --git a/manager_auth.go b/manager_auth.go index 2549faa..61a72fa 100644 --- a/manager_auth.go +++ b/manager_auth.go @@ -5,6 +5,7 @@ import ( "context" "encoding/base64" "errors" + "github.com/ProtonMail/go-srp" "github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/go-resty/resty/v2" @@ -19,7 +20,7 @@ func (m *Manager) NewClient(uid, acc, ref string) *Client { func (m *Manager) NewClientWithRefresh(ctx context.Context, uid, ref string) (*Client, Auth, error) { c := newClient(m, uid) - auth, err := m.authRefresh(ctx, uid, ref) + auth, err := m.authRefresh(ctx, uid, ref, "") if err != nil { return nil, Auth{}, err } @@ -105,7 +106,7 @@ func (m *Manager) auth(ctx context.Context, req AuthReq, hv *APIHVDetails) (Auth return res.Auth, nil } -func (m *Manager) authRefresh(ctx context.Context, uid, ref string) (Auth, error) { +func (m *Manager) authRefresh(ctx context.Context, uid, ref, acc string) (Auth, error) { state, err := crypto.RandomToken(32) if err != nil { return Auth{}, err @@ -118,6 +119,7 @@ func (m *Manager) authRefresh(ctx context.Context, uid, ref string) (Auth, error GrantType: "refresh_token", RedirectURI: "https://protonmail.ch", State: string(state), + AccessToken: acc, } var res struct { diff --git a/manager_auth_types.go b/manager_auth_types.go index a881608..75b22d6 100644 --- a/manager_auth_types.go +++ b/manager_auth_types.go @@ -97,6 +97,7 @@ type AuthRefreshReq struct { GrantType string RedirectURI string State string + AccessToken string `json:",omitempty"` } type AuthSession struct {