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

Logout API not working #10

Open
tanwirahmad opened this issue Oct 15, 2020 · 9 comments
Open

Logout API not working #10

tanwirahmad opened this issue Oct 15, 2020 · 9 comments
Assignees

Comments

@tanwirahmad
Copy link

tanwirahmad commented Oct 15, 2020

Hi, I am using the python client to logout a user. Unfortunately, I am getting the following response from the server.

{
   "fieldErrors":{
      "global":[
         {
            "code":"[couldNotConvert]global",
            "message":"Invalid"
         }
      ]
   }
}

Here is my code:

token = serializer.get_cleaned_data()["refreshToken"]
print(token)
client_response = anonymous_client.logout(True, token)

if not client_response.was_successful():
    code = client_response.response.status_code
    raise UnKnownError(http_code_number=code)

return Response({"detail": "Successfully logged out."}, status=status.HTTP_200_OK)

Versions
Fusionauth-client 1.19.8
FusionAuth 1.19.8

@mooreds
Copy link
Contributor

mooreds commented Oct 16, 2020

What happens if you try with

client_response = anonymous_client.logout(False, token)

do you still get an error?

@tanwirahmad
Copy link
Author

Yes, I get the same error. The HTTP status code is always 400.

@robotdan
Copy link
Member

My guess is that the True is not serializing to the lower case true when converted to a request parameter.

Here is where we build the request parameter:
https://github.com/FusionAuth/fusionauth-client-builder/blob/d64a871ba9d8fcedc7922bddced491ec80b5bd02/src/main/client/python.client.ftl#L76

And here is where we manage conversions for Python:
https://github.com/FusionAuth/fusionauth-client-builder/blob/d64a871ba9d8fcedc7922bddced491ec80b5bd02/src/main/client/_macros.ftl#L197

So we may have a bug in our builder since we should probably expect True or False.
https://docs.python.org/3/library/stdtypes.html#bltin-boolean-values

As a work around, what if you try passing "true" instead of True and see if that helps.

@tanwirahmad
Copy link
Author

As a work around, what if you try passing "true" instead of True and see if that helps.

This fixes the issue. Should I close it?

@mooreds
Copy link
Contributor

mooreds commented Oct 19, 2020

Please leave it open, so we can fix the issue. As @robotdan says, we should handle True correctly.

@mooreds mooreds self-assigned this Dec 15, 2020
mooreds added a commit that referenced this issue Dec 15, 2020
Working around this rather than fixing it because of future plans to overhaul client libs. If those don't work, should circle back and fix this by modifying client builder freemarker to stringify and lowercase all boolean args.
@mooreds
Copy link
Contributor

mooreds commented Dec 15, 2020

#11 documents the workaround.

mooreds added a commit to FusionAuth/fusionauth-client-builder that referenced this issue May 2, 2022
FusionAuth/fusionauth-python-client#10 is the issue.

when we are handed a True object, we need to serialize it to the string 'true'.

In staticly typed languages we use a converter. I didn't think python had one, so just brute forced it with a function call.
@mooreds
Copy link
Contributor

mooreds commented May 2, 2022

Have a fix for this in the code: FusionAuth/fusionauth-client-builder#46

@mooreds
Copy link
Contributor

mooreds commented May 4, 2022

Added test for it here: #16

This test will fail until there's a new release, but I've checked it manually and FusionAuth/fusionauth-client-builder#46 will cause the test to pass.

@mooreds
Copy link
Contributor

mooreds commented May 5, 2022

The fix is merged and will be included in the next release of the client library.

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

3 participants