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

[BUG] OAuth URI Errors #483

Open
4 tasks done
DancingPete opened this issue Sep 30, 2024 · 1 comment
Open
4 tasks done

[BUG] OAuth URI Errors #483

DancingPete opened this issue Sep 30, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@DancingPete
Copy link

DancingPete commented Sep 30, 2024

Bug Description

According to your OAuth documentation, I should be able to call client.login_link() to generate the href for the Oauth redirect handler. However, the sever errors out with the following message:

TypeError: WebApplicationClient.login_link() missing 1 required positional argument: 'redirect_uri'

After much fiddling, I've realized that perhaps the error is the result of the documentation that needs updating. A "more heavily commented example" provides a significantly different workflow which works perfectly.

If I am correct, I would be happy to contribute an updated documentation page. That said, a code update to align the flow with the documentation may be a better approach.

Reproducible Example

# Standard library imports
from os import environ

# Third-party imports
from fasthtml.common import *
from fasthtml.oauth import *

# Constants
GOOGLE_OAUTH_CLIENT_ID = environ.get("GOOGLE_OAUTH_CLIENT_ID")
GOOGLE_OAUTH_CLIENT_SECRET = environ.get("GOOGLE_OAUTH_CLIENT_SECRET")
GOOGLE_OAUTH_REDIRECT = environ.get("GOOGLE_OAUTH_REDIRECT")

# App definition
app, rt = fast_app(debug=environ.get("DEBUG"), live=environ.get("LIVE"))

# Define Google app client
client = GoogleAppClient(
    client_id=GOOGLE_OAUTH_CLIENT_ID,
    client_secret=GOOGLE_OAUTH_CLIENT_SECRET,
    redirect_uri=GOOGLE_OAUTH_REDIRECT)
link = client.login_link()

@rt("/")
def get(): return A(href=link)


@rt("/redirect")
def get(code: str): return P(f"code: {code}")

Note that when creating the client with the from_file(FILE_NAME) class method, everything work swimmingly.

Expected Behaviour

I would expect the client.login_link() to produce the redirect necessary to the oauth flow as described in the documentation walkthrough.

Note that while adding the redirect URI to the method call (i.e. login_link) generates a working link and successfully process the authentication flow, afterwards, the use of retr_id and retr_info both require the redirect URI as positional arguments unlike the the oauth walkthrough documentation, and here, adding the redirect URI fails.

Environment Information

Please provide the following version information:

  • fastlite version: 0.0.11
  • fastcore version: 1.7.10
  • fasthtml version: 0.6.9

Confirmation

Please confirm the following:

  • I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
  • I have provided a minimal reproducible example
  • I have included the versions of fastlite, fastcore, and fasthtml
  • I understand that this is a volunteer open source project with no commercial support.

Additional context

Screenshots

@DancingPete DancingPete added the bug Something isn't working label Sep 30, 2024
@algal
Copy link
Contributor

algal commented Oct 1, 2024

I just encountered the same issue with exactly those versions, not only with login_link() but also with .retr_id().

@algal algal self-assigned this Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants