Skip to content

JWK not found | callback url #87

@dyslechtchitect

Description

@dyslechtchitect

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions