Skip to content
TORNLIFE More

Weird API permission error codes

Started by Natty_Boh [1651049] on in Bugs & Issues.

10 replies · 504 views · thread synced · 4 days ago · View on torn.com
About this thread

Posts archived: 11 / 11 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
11
Discussion span
→
People posting
8
Likes on archived posts
4
Posts by staff, officers and moderators
4
Authority score
60 / 100
Historical score
51 / 100
Story score
48 / 100
Engagement score
59 / 100
Natty_Boh [1651049]
It looks like the permission of the key is checked before the ownership of the key is checked, leading to some weird/misleading error messages.

So like for example if I use my limited access key (everything but log) to request Ched's log, I get this error:
{ "error": { "code": 16, "error": "Access level of this key is not high enough", },}

But if I use that same key (which has permission for my events) to request Ched's events, I get this error:
{"error": {"code": 7,"error": "Incorrect ID-entity relation",},}

Seems like both should give the second error. As the issue with the first request isn't the keys permissions, its that the log requested is not the one associated with the key owner.

Also, fyi error code 16 isn't documented in the API docs yet.
Natty_Boh [1651049]
This also causes more weird behavior with certain fields that have different results based on if the requested data is the key owners or someone elses.

For example, personalstats. If I use my public or minimal access key to access someone elses personalstats, I get an error code 16.

But if I use my high limited/full access key to access someone elses personalstats, it works.

This is also seen when requesting my own personalstats with my own minimal/public key. I get an error code 16 instead of the publicly available version of the response. (ie with battle stats, etc removed)
Chedburn [1] Admin Developer
Yes it's definitely checked before everything else, and it has to. But we've already been discussing long-term solutions.
VanilaNightmare [2310825]
I'm also seeing inappropriate error codes but under different circumstances...figure I would just piggy back off this B&I post.

"https://api.torn.com/user/?selections=Log&log=5700,5705,5710,5715,5720,5725,5730,5735,6791,8842&key=" + <Full Access API key> yields error code 16

"https://api.torn.com/user/?selections=log&log=5700,5705,5710,5715,5720,5725,5730,5735,6791,8842&key=" + <Full Access API key> works perfectly fine with the same "Full Access" API key.

The capitalized "L" in "Log" appears to be causing the error, not the API key access level, yet its returning the access level error code

This issue just started happening today...
Ahab [1735214]
https://api.torn.com/faction/userId?selections=profile
Gives error 16 even though I don't believe that url even exists
aurel1 [1046304] Admin Staff
Because of some limitations we really need to check that permissions first (before the relation check, for example), I afraid we can't really change this atm, perhaps we can reword the error or just leave it?
Chedburn [1] Admin Developer
Unless we have a list of all possible selections to check first, so we can produce the "4 => Wrong fields : Requesting incorrect selection fields." error before everything else perhaps.
Spofforth [2692779]
So what should people do if they are getting `Access level of this key is not high enough`?

Is there a workaround we should be using?