appdotnet / api-spec

App.net API Documentation is on the web at https://developers.app.net. Source for these docs is in the new-docs branch here. Please use the issue tracker and submit pull requests! Help us build the real-time social service where users and developers come first, not advertisers.

Home Page:https://developers.app.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IDs returned as raw numbers from oauth/access_token, but as quoted strings from other endpoints.

tonyarnold opened this issue · comments

I can probably work around this, but is there a reason why user and other IDs are returned as raw numbers from https://account.app.net/oauth/access_token, but as quoted strings from other endpoints?

If not, it would be great to see them both consistent.

It's related to some inconsistent old code, unfortunately. We should be returning the full object you'd get from /stream/0/token in the response as well under the token key. For consistency with the rest of the API, I suggest consuming that object instead. Let me know if you don't see it and I'll make sure that it's there.

Hi @berg, thanks for the quick response — token.user is there, however I was already using it — the IDs in this part of the response are also "raw" and unquoted.

I can't reproduce this, when I go through the password grant flow for one of my apps token.user.id is a string.

Which grant type are you using?

I'm using "password". I've tested through a few different clients, and the IDs (and other values) are coming through unquoted in the JSON response from the ADN server.

Ie. Current response is:

id = 3104;

Whereas I'd expect (if the ID is supposed to be a string) that it would be:

id = "3104";

curl -k https://account.app.net/oauth/access_token -d 'client_id=CLIENT_ID&password_grant_secret=PASSWORD_SECRET&grant_type=password&username=USERNAME&password=PASSWORD'

gets me:

{
    "access_token": "...",
    "username": "mthurman",
    "token": {
        ...
        "user": {
            ...
            "id": "8",
            ...
        },
        ...
    },
    "user_id": 8
}

If you'd like to follow up with a PM so I can try debugging this in real time, I'd love to try to track this down but I can't reproduce it.

I'm sorry, @mthurman — I neglected to test this using curl directly. The clients I tested with must be re-interpreting the data. One of them is AFNetworking, which isn't awesome — I'll take the issue over there.

Thanks for helping out!