Get user profile-picture without login

Hey,
I’m wondering if it’s possible to fetch any users profile picture by his name without having them log in. I’ve tried and read much but I keep getting 401 responses. Do I really need an OAuth token to fetch simple, public data like a profile picture?

Thanks in advance

Use an App Access Token, AKA “client credentials”

Which is for server to server requests/public data

Thanks for helping me that quickly,

I got an oAuth and make a get request as specified in the docs to the following URL:
https://api.twitch.tv/helix/users?login=Kozie1337

But my response does not include a data field as expected:

Is my URL correct? I’ve tried using uncapitalized names but it still doesn’t work.
Since the status is 200 the authorization at least isn’t the problem anymore.

Your code didn’t process/spit out the response.

So would need to see your code to help with the issue

I was using node-fetch before and data was undefined, now I switched to axios and it works out of a sudden. Thanks :slight_smile:

 axios
.get("https://api.twitch.tv/helix/users?login=Kozie1337", {
  headers: {
    "Client-Id": clientid,
    Authorization: "Bearer " + token,
  },
})
.then((res) => {
  console.log(res.data);
});

I don’t know axious

But I’m gonna guess you need to

 axios
.get("https://api.twitch.tv/helix/users?login=Kozie1337", {
  headers: {
    "Client-Id": clientid,
    Authorization: "Bearer " + token,
  },
    responseType: 'json'
})
.then((res) => {
  console.log(res.data);
});

The responseType will tell axois to expect and handle as JSON

And data should be the whole response object

Personally I use nodeJS Got myself

With node fetch you probablyt needed to do

fetch(url, {options})
    .then(resp => { return resp.json(); })
    .then(resp => {
        // do stuff with resp as it's the json blob that was returned
    });

This example might help,

But it’s front end JS

Or this backend example

Covers how Got works for accessing the body

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.