go-samples icon indicating copy to clipboard operation
go-samples copied to clipboard

Error Malformed auth code

Open xuanlongvts opened this issue 2 years ago • 2 comments

hi there,

from this demo: https://github.com/googleworkspace/go-samples/blob/master/gmail/quickstart/quickstart.go

I got an error with message:

2023/03/29 14:40:18 Unable to retrieve token from web: oauth2: cannot fetch token: 400 Bad Request Response: { "error": "invalid_grant", "error_description": "Malformed auth code." }

After i copy the url redirect from browser and then enter in command line, It shows the above error

xuanlongvts avatar Mar 29 '23 07:03 xuanlongvts

In my case it does open the authentication web page but at the end it redirects to an incorrect webpage: http://localhost/?state=state-token&code=XXXXXXXXX&scope=https://www.googleapis.com/auth/gmail.readonly

Code parameter censured for obvious reasons.

s4m1r0d4 avatar Nov 10 '23 02:11 s4m1r0d4

In my case it does open the authentication web page but at the end it redirects to an incorrect webpage: http://localhost/?state=state-token&code=XXXXXXXXX&scope=https://www.googleapis.com/auth/gmail.readonly

Code parameter censured for obvious reasons.

There is an workaround for this, I had the same problem: https://github.com/googleworkspace/go-samples/issues/76#issuecomment-1304902886

jsalgado2510 avatar Mar 14 '24 01:03 jsalgado2510