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

JWK not found | callback url #87

Open
dyslechtchitect opened this issue Mar 2, 2024 · 0 comments
Open

JWK not found | callback url #87

dyslechtchitect opened this issue Mar 2, 2024 · 0 comments

Comments

@dyslechtchitect
Copy link

dyslechtchitect commented Mar 2, 2024

Hi, I've setup my fastapi-cloudauth as the readme describes in Example (AWS Cognito),
but can't see anywhere to specify my cognito callback URL
and I'm getting a 401 error with:

{
    "detail": "JWK public Attribute for authorization token not found"
}

i'm calling my server like:

curl --location 'http://127.0.0.1:5000/access' \
--header 'Authorization: Bearer XXX

and my code is basically the hello world example:

import uvicorn
from pydantic import BaseModel
from fastapi import FastAPI, Depends
from fastapi_cloudauth.cognito import Cognito, CognitoCurrentUser, CognitoClaims

app = FastAPI()
auth = Cognito(
    region="eu-xxxx,
    userPoolId="eu-north-xxxx",
    client_id="xxxx"
)

@app.get("/", dependencies=[Depends(auth.scope(["read:users"]))])
def secure():
    # access token is valid
    return "Hello"


class AccessUser(BaseModel):
    sub: str


@app.get("/access/")
def secure_access(current_user: AccessUser = Depends(auth.claim(AccessUser))):
    # access token is valid and getting user info from access token
    return f"Hello", {current_user.sub}


get_current_user = CognitoCurrentUser(
    region="eu-xxxx,
    userPoolId="eu-north-xxxx",
    client_id="xxxx"
)


@app.get("/user/")
def secure_user(current_user: CognitoClaims = Depends(get_current_user)):
    # ID token is valid and getting user info from ID token
    return f"Hello, {current_user.username}"

`

Notes:

  1. I've checked the user pool and it works with other frameworks like flask
  2. I am able to manually see the cognito-idp url and the token there is valid
  3. the server is running on my localhost
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