Skip to content

Cannot get refreshtoken and user email #124

@BhuwanPandey

Description

@BhuwanPandey
@app.route('/callback')
def callback(request: Request):
    code = request.query_params.get('code')
    github = GitHub(OAuthAppAuthStrategy(settings.CLIENT_ID, settings.SECRET_ID))
    user_github = github.with_auth(github.auth.as_web_user(code))
    
    # Or exchange the code for tokens and store them
    auth: OAuthTokenAuthStrategy = github.auth.as_web_user(code).exchange_token(github)
    access_token = auth.token
    refresh_token = auth.refresh_token
    print(access_token)
    print(refresh_token)

    user_github = github.with_auth(
        OAuthTokenAuthStrategy(
        settings.CLIENT_ID, settings.SECRET_ID, refresh_token=refresh_token
        )
    )
    resp = user_github.rest.users.get_authenticated()
    user = resp.parsed_data
    print(user.email)

When I try to implement github authentication with oauth application,
In above, I provide valid client_id and secret_id

but I am not getting refresh_token , user.email
Can you please help me what might be the reason that I am facing this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions