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.
https://developers.app.net
950 stars 98 forks source link

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

Closed tonyarnold closed 11 years ago

tonyarnold commented 11 years ago

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.

berg commented 11 years ago

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.

tonyarnold commented 11 years ago

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.

mthurman commented 11 years ago

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?

tonyarnold commented 11 years ago

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";
mthurman commented 11 years ago

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.

tonyarnold commented 11 years ago

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!