# Get user profile-picture without login

**URL:** <https://discuss.dev.twitch.com/t/get-user-profile-picture-without-login/28735>\
**Category:** API\
**Created:** [October 22, 2020, 5:39pm UTC](https://discuss.dev.twitch.com/t/get-user-profile-picture-without-login/28735 "2020-10-22T17:39:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RealKozie](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/realkozie/32/12743_2.png) [@RealKozie](https://discuss.dev.twitch.com/u/RealKozie)\
**Post date:** [October 22, 2020, 5:39pm UTC](https://discuss.dev.twitch.com/t/get-user-profile-picture-without-login/28735/1 "2020-10-22T17:39:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 22, 2020, 5:40pm UTC](https://discuss.dev.twitch.com/t/get-user-profile-picture-without-login/28735/2 "2020-10-22T17:40:38Z")

</div>

Use an App Access Token, AKA “client credentials”

Which is for server to server requests/public data

> **[Getting OAuth Access Tokens](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/)**
>
> Getting OAuth Access Tokens

---

<div class="post-metadata">

**Author:** ![RealKozie](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/realkozie/32/12743_2.png) [@RealKozie](https://discuss.dev.twitch.com/u/RealKozie)\
**Post date:** [October 23, 2020, 4:24pm UTC](https://discuss.dev.twitch.com/t/get-user-profile-picture-without-login/28735/3 "2020-10-23T16:24:21Z")

</div>

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](https://api.twitch.tv/helix/users?login=Kozie1337)”

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

 ![image](https://d2opxh93rbxzdn.cloudfront.net/original/2X/c/c48d32c6b8d3752f1a3d940a1050c4b5ede8eb6e.png)

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.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 23, 2020, 4:25pm UTC](https://discuss.dev.twitch.com/t/get-user-profile-picture-without-login/28735/4 "2020-10-23T16:25:33Z")

</div>

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

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

 ![image](https://d2opxh93rbxzdn.cloudfront.net/original/2X/5/58838509af1e491737be9c7a4f1fa063f101defd.png)

---

<div class="post-metadata">

**Author:** ![RealKozie](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/realkozie/32/12743_2.png) [@RealKozie](https://discuss.dev.twitch.com/u/RealKozie)\
**Post date:** [October 23, 2020, 4:29pm UTC](https://discuss.dev.twitch.com/t/get-user-profile-picture-without-login/28735/5 "2020-10-23T16:29:03Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 23, 2020, 4:35pm UTC](https://discuss.dev.twitch.com/t/get-user-profile-picture-without-login/28735/6 "2020-10-23T16:35:23Z")

</div>

I don’t know axious

But I’m gonna guess you need to

```auto
 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

```auto
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,

> **[Twitch Implicit Auth Example](https://barrycarlyon.github.io/twitch_misc/authentication/implicit_auth/)**

But it’s front end JS

Or this backend example

> <https://github.com/BarryCarlyon/twitch_misc/blob/master/authentication/app_access_tokens/nodejs/twitch.js#L47>

Covers how Got works for accessing the body

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [November 22, 2020, 4:35pm UTC](https://discuss.dev.twitch.com/t/get-user-profile-picture-without-login/28735/7 "2020-11-22T16:35:24Z")

</div>

Closed on November 22, 2020, 4:35pm UTC

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