Invalid OAuth in game - works when testing in Postman

Hey! I’ve read through a number of topics on this subject but can’t find an answer that works for me.

I’m running a simple get helix/users query in my game to grab the player’s ID, and while testing it in Postman it works absolutely fine and the details are retrieved. As soon as it is run in my game though I get error 401 - any ideas?

        UnityWebRequest www = UnityWebRequest.Get("https://api.twitch.tv/helix/users?login=" + user.ToLower());
        www.SetRequestHeader("Authorization", bearer);
        www.SetRequestHeader("Client-Id", clientid);
        yield return www.SendWebRequest();

The ClientID and Bearer are brand new (and correct, hence it working in Postman).

Cheers

What is the body of the response.

HTTP code is half the information.

This is what I get in Postman:

{
“data”: [
{
“id”: “83277609”,
“login”: “ibzy_”,
“display_name”: “Ibzy_”,
“type”: “”,
“broadcaster_type”: “affiliate”,
“description”: “Returning after a long hiatus, getting back into the swing of things with Splitgate, Phantom Abyss, and interactive classic DOOM streams. Enquiries: Lee@ibzy.co.uk”,
“profile_image_url”: “https://static-cdn.jtvnw.net/jtv_user_pictures/6ea7e9a4-6694-470d-b412-e06ccc2c2ee1-profile_image-300x300.png”,
“offline_image_url”: “https://static-cdn.jtvnw.net/jtv_user_pictures/4af69a58-50e1-45ff-ad3d-0111adc05ff4-channel_offline_image-1920x1080.png”,
“view_count”: 69522,
“created_at”: “2015-02-20T23:21:04Z”
}
]
}

And this is in my debug.log:

{“error”:“Unauthorized”,“status”:401,“message”:“Invalid OAuth token”}

The token used inside your app is invalid.

I’m using the exact same token, I literally copy pasted from my code to postman and it works outside the app

You sure your header is connectly formed with BearerSPACEthetoken

I am.

However, I am now working on a time machine to slap my past self. Added a debug.log(bearer) and got given a different token. Any guesses?

Yep, I left it as an open property and it was being overridden in Unity.

Thanks for your help, Barry