Twitter SDK for Unity: Bad Authentication Data, error code 215

So i am simply trying to get the user’s name. Not the screen_name, just the name that the user could change constantly. According to the docs, i could get it by retrieving the User Object which contains all the user’s data. The problem here is whenever i try to retrieve it using (“https://api.twitter.com/1.1/users/show.json?screen_name=userName”), i always get the following error: {“errors”:[{“code”:215,“message”:“Bad Authentication data.”}]}.

Here i am using Unity SDK. Which after authentication gives me access to userName, authToken, and id.

i can’t find anything useful on the internet regarding this, since using Twitter API in a game is very rare.

This is the code that i am using at the moment:

IEnumerator GetDisplayName(string userID)
{
    using (WWW www = new WWW("https://api.twitter.com/1.1/users/show.json?screen_name=" + userID))
    {
        yield return www;
        string json = www.text;
        JsonUtility.FromJson<WWW>(json);

        yield return www;

        foreach (var item in json)
        {
            Debug.Log(www.text);
        }
    }
}

Note: i call this function after i successfully authenticate.

So is it even possible to do this in Unity? and if so, what am i doing wrong?

Any help is very much appreciated.

Hello @Geads. Yes I managed to solve the issue and successfully send the request and get the response. There is an asset on the Assets store that shows you how to do it in details. From that code and the Twitter API docs, you can figure out all that you need to do… here’s the link to the asset.

Please support the owner of the asset as well, all credits go to them. And do let me know if you need further help.

Did you ever figure this out?