Search code examples
uber-api

Uber oauth2.0 login redirecting too many time


enter image description here

I'm trying to set up a 3rd party service that uses the Uber APIs to pull client history. I've got a local Flask app running which does the auth_flow and redirects to the Uber login page. After entering correct credentials, it appears that the redirect is never ending, hence the error in the image posted.

import os
from datetime import datetime
from flask import Flask, request, flash, url_for, redirect, \
     render_template, abort, send_from_directory, redirect
from uber_rides.auth import AuthorizationCodeGrant

app = Flask(__name__)
app.config.from_pyfile('flaskapp.cfg')

# Configure Uber Oauth2.0
auth_flow = AuthorizationCodeGrant(
    '<client_id>',
    'history',
    '<client_secret>',
    'http://localhost:8080'
    )

@app.route('/')
def index():
    auth_url = auth_flow.get_authorization_url()
    return redirect(auth_url, code=302)

if __name__ == '__main__':
    app.run(debug=True)

That is my code. In the Uber developer dashboard, I've added http://localhost:8080 as the redirect URI and checked the history option under scopes.

What am I doing wrong?


Solution

  • I don't see any route for the callback ... Looks like what happens is: User opens app, gets redirected to auth_url (I assume that's the Uber auth page), user authorizes your app, user gets redirected to http://localhost:8080. This redirect is hitting the index route and user gets back to auth_url. The second time a user sees the Uber auth page his session is still valid and he gets redirect back to http://localhost:8080.. This creates a never-ending loop.

    A solution would be set the redirect URL to hit a different callback route, e.g. http://localhost:8080/callback.