Beginner here. When trying to exchange my authorization grant for an access token to access google's api, i keep running into redirect uri mismatch error, however on checking my google cloud console, my authorized redirect uris are an exact match, including http and trailing slashes. My authorized javascript origin is also an exact match. The user authorization process goes fine and returns a code
Below is my code for the authorization process and the token exchange:
@app.route("/youtubeauth")def youtubeauth(): yt_auth_dict={"scope":"https://www.googleapis.com/auth/youtube","client_id":youtube_client_id,"response_type":"code","redirect_uri":"http://localhost:8888/tokenexchange","prompt":"consent" } yt_auth_url="https://accounts.google.com/o/oauth2/auth?"+urllib.parse.urlencode(yt_auth_dict) print(yt_auth_url) return redirect (yt_auth_url)@app.route("/tokenexchange")def tokenexchange(): code = request.args.get('code') if code: #obtaining access token print(code) params = {'code': code,'client_id': youtube_client_id,'client_secret': youtube_client_secret,'redirect_uri': 'http://localhost:8888/example','grant_type': 'authorization_code' } tokenrequest=requests.post('https://oauth2.googleapis.com/token',data=params) return tokenrequest.json()