Google Drive API Quickstart.py Error 400: redirect_uri_mismatch

Question:

I’m using the https://developers.google.com/drive/api/v3/quickstart/python to access the Google Drive Api but Google keeps throwing redirect_uri_mismatch errors.

I add the localhost:number from the error to the Authorised redirect URIs in the client ID for the Web Application, but whenever I run the quickstart.py, the local host number changes.

I see there are loads of questions regarding this matter on StackOverflow and I’ve already spent hours looking to fix mine but I haven’t found an answer that seems to solve it for me.

Any ideas?


Tried answers from, amongst others,


Currently

enter image description here

Asked By: LucSpan

||

Answers:

Tanaike‘s comment and answer here worked: Google APIs OAuth 2.0 redirect_uri_mismatch error

So in quickstart.py, make the following change,

creds = flow.run_local_server(port=0) 

to,

creds = flow.run_local_server(port=8080) 

when http://localhost:8080/ is on the URIs list.

Answered By: LucSpan

Like LucSpan mentioned in the comments of the answer. the redirect URI needs to be "http://localhost:8080/" and not "http://localhost:8080" the missing "/" at the end matters

Answered By: kritin