keybase / keybase-issues

A single repo for managing publicly recognized issues with the keybase client, installer, and website.
902 stars 37 forks source link

Keybase API Question #1610

Open exsystemctl opened 9 years ago

exsystemctl commented 9 years ago

Hey Keybase team, I have a question regarding the API. I am developing a simple desktop app for Keybase, but I have already hit a road block while trying to login via the API. After sending a login request, I am returned with the status code 202. The description for this code is as follows: "Failed to purepack.unpack". Lastly, the "name" I am given is "BAD_SESSION". I am just wondering what I have done wrong.

Thanks, systemCTL.

eric-zeng commented 8 years ago

Hi, so I was getting the same error when implementing logins for my browser/node.js client. It might not be the problem you were having, but I figured I would share anyways.

When you perform the 2-step login process, you get a base64 encoded string 'login_session' from the getsalt.json endpoint, and need to pass it back to the login.json endpoint with the same encoding. getsalt.json returns the login_session in response body, in a JSON object. login_session needs to be sent back to login.json in the query string. However, it is possible that login_session contains non URL-safe characters. This is why I was getting BAD_SESSION even though it looked like I was sending the same login_session from getsalt.json to login.json.

I tried fixing this by using the node library URLSafe-Base64, which replaces '+' with '-', '/' with '_', and drops the padding character '='. However, Keybase doesn't accept this form of url-safe base64 strings. I had to replace '+', '/', and '=' with their URL percent escape characters, '%2B', '%2F', and '%3D' respectively. Now, I'm able to login consistently without errors.

Hopefully this fixes your issue - if not, maybe this will help someone trying to implement Keybase client on node/browser.