Twitch lets users create user names that conflict with other user’s id. Since the API to access either by user id or user name is the same, this can lead to some very unexpected security issues (e.g. impersonation on services).
For example:
curl -s -H "Client-ID: $CLIENT_ID" https://api.twitch.tv/kraken/users/waneck
{"display_name":"waneck","_id":28730891,"name":"waneck","type":"user","bio":null,"created_at":"2012-03-05T02:12:04Z","updated_at":"2017-02-24T14:35:35Z","logo":null,"_links":{"self":"https://api.twitch.tv/kraken/users/waneck"}}
I was able to create a new user called 28730891:
curl -s -H "Client-ID: $CLIENT_ID" https://api.twitch.tv/kraken/users/28730891
{"display_name":"28730891","_id":148593651,"name":"28730891","type":"user","bio":null,"created_at":"2017-02-24T14:43:18Z","updated_at":"2017-02-24T14:43:19Z","logo":null,"_links":{"self":"https://api.twitch.tv/kraken/users/28730891"}}
So when we migrate to the new api, we get this:
curl -s -H 'Accept: application/vnd.twitchtv.v5+json' -H "Client-ID: $CLIENT_ID" https://api.twitch.tv/kraken/users/28730891
{"display_name":"waneck","_id":"28730891","name":"waneck","type":"user","bio":null,"created_at":"2012-03-05T02:12:04.958217Z","updated_at":"2017-02-24T14:35:35.349913Z","logo":null}
Ideally, the API should have a way to specify whether we want to access a user by id or by name, and it would be nice if numerical user names were reserved so we are sure this can’t be exploited.