Access blocked: This app’s request is invalid

Please assist with this code. I am trying to build a data pipeline using Python to connect to Google Bigquery. I am having trouble getting a token etc.
ac
ac2

My code is

Blockquote
import os

import requests

from google.cloud import storage

Replace the following with your own values

client_id = ‘708656351089-sr69er76a33j79b2mk9e3u188l6d5l6m.apps.googleusercontent.com

client_secret = ‘GOCSPX-3r’

redirect_uri = ‘https://www.googleapis.com/auth

scope = ‘YOUR_SCOPES’ # e.g. ‘https://www.googleapis.com/auth/calendar

Update with provided information

client_id = ‘708656351089-sr69er76a33j79b2mk9e3u188l6d5l6m.apps.googleusercontent.com

client_secret = ‘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’

redirect_uri = ’

scope = ‘https://www.googleapis.com/auth/calendar

Step 1: Redirect the user to the authorization URL

authorization_url = f’Sign in - Google Accounts

print(‘Please go to the following URL to authorize the application:’)

print(authorization_url)

Step 2: Retrieve the authorization code from the user

authorization_code = input('Enter the authorization code: ')

Step 3: Exchange the authorization code for an access token and refresh token

token_url = ‘https://oauth2.googleapis.com/token

token_payload = {

‘code’: authorization_code,

‘client_id’: client_id,

‘client_secret’: client_secret,

‘redirect_uri’: redirect_uri,

‘grant_type’: ‘authorization_code’

}

token_response = requests.post(token_url, data=token_payload)

token_data = token_response.json()

Access token and refresh token

access_token = token_data[‘access_token’]

refresh_token = token_data[‘refresh_token’]

Use the access token to make API requests

e.g. headers = {‘Authorization’: f’Bearer {access_token}'}

response = requests.get(‘https://api.example.com’, headers=headers)

Blockquote

Firstly, there’s something wrong with the block quoting, so only the first part is readable.

Secondly, your secrets are now exposed. You’ll need to regenerate them.

Third, though: You seem to have duplicate assignments here; it’s possible the first one is correct, but I suspect the second one isn’t (unless it’s caused by a post format issue). Make sure the redirect_uri matches what you told Google that you’d be using.