Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple OAuth clients registered #30

Open
cesarqdt opened this issue Oct 3, 2023 · 0 comments
Open

Multiple OAuth clients registered #30

cesarqdt opened this issue Oct 3, 2023 · 0 comments

Comments

@cesarqdt
Copy link

cesarqdt commented Oct 3, 2023

When there are more than 1 oauth client to connect, the application always picks the last one in the definition instead of any of the defined ones. There should be a way to keep every client registered and usable in subsequent calls. This is the example:

# 1. Register client_1
oauth.register(
        "client_1",
        client_id = client_id,
        client_secret = client_secret,
        client_kwargs = {
            "scope": "openid profile email",
        },
        server_metadata_url = f'{domain}/.well-known/openid-configuration'
    )


# 2. Register client_2
oauth.register(
        "client_2",
        client_id = client_id_2,
        client_secret = client_secret_2,
        client_kwargs = {
            "scope": "openid profile email",
        },
        server_metadata_url = f'{domain_2}/.well-known/openid-configuration'
    )


@app.route('client_1/login')
def client_1_login():
    return oauth.client_1.....

@app.route('client_2/login')
def client_2_login():
    return oauth.client_2....

when someone accesses route client_1/login, an error will raise with the following traceback:

Traceback (most recent call last):
  File "/usr/src/app/.local/lib/python3.9/site-packages/flask/app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/src/app/.local/lib/python3.9/site-packages/flask/app.py", line 1525, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/src/app/.local/lib/python3.9/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/src/app/.local/lib/python3.9/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/src/app/.local/lib/python3.9/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/src/app/app/views/auth.py", line xxx, in client_1_login
    token = oauth.client_1.authorize_access_token()
  File "/usr/src/app/.local/lib/python3.9/site-packages/authlib/integrations/base_client/registry.py", line 118, in __getattr__
    raise AttributeError('No such client: %s' % key)
AttributeError: No such client: client_1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant