fastapi-sso icon indicating copy to clipboard operation
fastapi-sso copied to clipboard

getting back empty user info from await sso.verify_and_process(request)

Open markmjm opened this issue 2 years ago • 2 comments

Hello

I am using the generic option. I am seeing this warning:

fastapi_sso.sso.generic - WARNING - No response convertor was provided, returned OpenID will always be empty

from this call.

 a_user = await sso.verify_and_process(request)
    return {
        "id": a_user.id,
        "picture": a_user.picture,
        "display_name": a_user.display_name,
        "email": a_user.email,
        "provider": a_user.provider
    }

please advise how to implement the response converter.

Thank you

markmjm avatar Sep 06 '22 14:09 markmjm

The response convertor is a callable accepting the response content (most probably a dictionary) and returning OpenID object. If your userinfo endpoint returns something like this:

{
     "id": 1,
     "name": "ijustfarted",
     "email": "[email protected]",
     "picture": "https://unsplash.it/200"
}

Your convertor will look like this:

def openid_convertor(response: Dict[str, Any]) -> OpenID:
    return OpenID(
        id=response["id"],
        email=response["email"],
        display_name=response["name"],
        picture=response["picture"]
    )

Is this understandable enough? If so, I will mention this issue in the docs. If you have any more questions, please let me know.

tomasvotava avatar Oct 21 '22 21:10 tomasvotava

Closed the issue by mistake, sorry. It's open again. Let me know if I can close it.

tomasvotava avatar Oct 21 '22 21:10 tomasvotava

Closing for inactivity :ok_hand:

tomasvotava avatar Jan 23 '23 11:01 tomasvotava