google / gmail-oauth2-tools

Tools and sample code for authenticating to Gmail with OAuth2
Apache License 2.0
405 stars 211 forks source link

sendgmail: refresh token hack no longer works #61

Closed richardweinberger closed 1 year ago

richardweinberger commented 1 year ago

https://github.com/google/gmail-oauth2-tools/blob/912b0c18fae21c07ec3c78ee58b6ba1e7a4e4f15/go/sendgmail/main.go#L98 states:

fmt.Println(authCodeURL + "&access_type=offline") // hack to obtain a refresh token

but all I get is an access token. Only when I add &prompt=consent too beside of the access token a refresh token is returned. Is this desired?

junyer commented 1 year ago

Many thanks for the report! It does indeed seem that prompt=consent is needed for consistently obtaining a refresh token.