Recent searches


No recent searches

401 Error in loginuser method when using SDK



Posted May 22, 2024

After looking at the documents provided by Zendesk, we are making JWT on our server and delivering it to the app. If you deliver the JWT to Zendesk through the loginUser function within the SDK, you are currently getting 401 errors, so the work will not proceed.

I've been looking at the document for days now, but I couldn't figure out where it was wrong.
 


1

5

5 comments

Additionally, in the case of JWT, it will be delivered as follows.


And the part where the received JWT value is put in the SDK is as follows.

0


Hello, I kept getting 401 errors yesterday when I was testing the authentication of messaging widget on my Help Center using jwt.io. So my code looks a bit different.

In the end I realized that my payload was wrong:

{

      "scope": "user",

      "external_id": "this-is-a-string",

      "email": "email@emai.com", 

      "email_verified": true

 }
and secret base64 encoded had to be unchecked as I was not decoding it.

0


thank you for reply Beatrice Schembri.

I made "external_id" a String with the hint you gave me, but it's still getting 401 errors. TT

0


Can you console log the logged in user and the token you are passing to the widget? In my case, first I was sending a badly formed request to the backend, then when I fixed that I returned a whole object and not just the token, so authorization did not pass (again, for me it was about authenticating from Help Center to messaging chat, but adapt to your case).

0


I checked the console log where there was a problem with the JWT token I made. 
1. “userId” should not be used.
2. The “scope” is missing.
I've checked the above two and it's currently being called normally. Thank you for your care.

1


Please sign in to leave a comment.

Didn't find what you're looking for?

New post