# Fetch json with token

**URL:** https://community.glideapps.com/t/fetch-json-with-token/53097
**Category:** Ask for Help
**Created:** [November 2, 2022, 6:47am UTC](https://community.glideapps.com/t/fetch-json-with-token/53097 "2022-11-02T06:47:46Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mohammad\_altoiher](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mohammad_altoiher/32/50001_2.png) [@mohammad\_altoiher](https://community.glideapps.com/u/mohammad_altoiher)
#### Post date: [November 2, 2022, 6:47am UTC](https://community.glideapps.com/t/fetch-json-with-token/53097/1 "2022-11-02T06:47:46Z")

</div>

Hi 👋  
I’m new here and seeing that i can use my external API was really great!  
but my API require a user-token in the headers of the request. is this possible to achieve?

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [November 3, 2022, 12:45am UTC](https://community.glideapps.com/t/fetch-json-with-token/53097/2 "2022-11-03T00:45:42Z")

</div>

I’m not sure if anyone has ever cracked it, but we discussed about it here.

> [@Fetch JSON with authorization headers](https://community.glideapps.com/t/fetch-json-with-authorization-headers/42592):
>
> Is there any way to fetch json from an API that requires authorization headers to be sent with a bearer token?

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [November 3, 2022, 2:04am UTC](https://community.glideapps.com/t/fetch-json-with-token/53097/3 "2022-11-03T02:04:17Z")

</div>

Maybe a javascript column that sets the headers and calls the API?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [November 3, 2022, 2:05am UTC](https://community.glideapps.com/t/fetch-json-with-token/53097/4 "2022-11-03T02:05:29Z")

</div>

Never had a reason to try it, but yeah I expect that would work.

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [November 3, 2022, 2:22am UTC](https://community.glideapps.com/t/fetch-json-with-token/53097/5 "2022-11-03T02:22:37Z")

</div>

Yeah, not something I’ve needed to do within glide either…yet.

---

<div class="post-metadata">

### Author: ![mohammad\_altoiher](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mohammad_altoiher/32/50001_2.png) [@mohammad\_altoiher](https://community.glideapps.com/u/mohammad_altoiher)
#### Post date: [November 3, 2022, 7:43am UTC](https://community.glideapps.com/t/fetch-json-with-token/53097/6 "2022-11-03T07:43:27Z")

</div>

i saw this in the threat you linked @ThinhDinh  
“requires the token to be sent in headers”

i have searched but no one have did it before.  
if someone is able to achieve this then i will use glide for sure.

i will be able to use my backend server with this approach and make all sort of server logic 👍

---

<div class="post-metadata">

### Author: ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)
#### Post date: [November 3, 2022, 11:45am UTC](https://community.glideapps.com/t/fetch-json-with-token/53097/7 "2022-11-03T11:45:01Z")

</div>

Hola!

I think it’s possible but if you share your cURL command (or Fetch syntax) we can try to fix it.

Your JS code might look like:

```auto
var data= await fetch('YOUR_URL', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': 'YOUR_BearerToken'
    },
});

const json = await data.text(); // or data.json();   
return json

```

Saludos!

---

<div class="post-metadata">

### Author: ![mohammad\_altoiher](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mohammad_altoiher/32/50001_2.png) [@mohammad\_altoiher](https://community.glideapps.com/u/mohammad_altoiher)
#### Post date: [November 4, 2022, 5:32pm UTC](https://community.glideapps.com/t/fetch-json-with-token/53097/8 "2022-11-04T17:32:45Z")

</div>

this is awesome!  
i will give this a shot

---

<div class="post-metadata">

### Author: ![Wisdom\_seeker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/wisdom_seeker/32/50356_2.png) [@Wisdom\_seeker](https://community.glideapps.com/u/Wisdom_seeker)
#### Post date: [November 24, 2022, 8:13pm UTC](https://community.glideapps.com/t/fetch-json-with-token/53097/9 "2022-11-24T20:13:31Z")

</div>

Hi Mohammad,  
Did it work for you? If yes, I also try it.
