1

I'm new to using Google APIs in general. Could anyone help me figure out how to set up this tasks API correctly for my python/flask/sqlalchemy application?

I got the API key, client ID (and downloaded as credentials.json), pip installed the Quickstart for python, created the quickstart.py and credentials.json with provided code but when I ran that quickstart.py file, it says

"Error 400: redirect_uri_mismatch. The redirect URI in the request, http://localhost:51014/, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/${your_client_id}?project=${your_project_number}"

When I tried each time, the port number kept changing.

On my terminal, it says

"lease visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=624465110094-oa56kshqc0vml0k2uju45ro7tjg0jo8j.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A51014%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ftasks.readonly&state=8MQQOCU8Do80dheS9iuRZJnG2E1gzx&access_type=offline"

I think I set up the wrong URI somehow. Could someone tell me the correct way of setting up the OAuth consent screen section? For my project, I ran my app on localhost:5000 then deployed it to Heroku (mysite.herokuapp.com). I'm not sure what I need to put on "Authorized domains" field and "Application homepage link". (I didn't add anything under " Add Scope".)

Also under "credentials" section, what URI I should put in the "Authorized JavaScript origins" and "Authorized redirect URIs" field? So far I put "http://localhost:5000" and it's not accepting this format. So left it blank but I got this error 400 at the end. For "type", I chose "web application". Should I choose web server instead?

Thanks!

allaroundcoder
  • 169
  • 1
  • 11
  • Can you please provide the code you're working on? Are you following [this quickstart](https://developers.google.com/tasks/quickstart/python)? – Iamblichus Oct 20 '20 at 07:52
  • Yes, I fixed it by adding "/" after 5000 for the redirect URI. Then I submitted the consent screen for verification. But I got the email back saying it doesn't need to be verified because my site is for internal usage. I thought after I deployed my site to Heroku that allows any users to try out my site, it's public user not internal user scenario. – allaroundcoder Oct 23 '20 at 06:40
  • When setting the consent screen, if you set the application to be `Internal`, it can only be accessed by users in your domain. – Iamblichus Oct 23 '20 at 08:48
  • Yes, I understand when to use internal but in my case, I believe I need to be external because users access to my app via herokuapp.com. That's why I didn't understand why Google didn't want to proceed to validate my OAuth request. – allaroundcoder Oct 30 '20 at 04:01

0 Answers0