# Rtk Query and auth0

**URL:** <https://community.auth0.com/t/rtk-query-and-auth0/73851>\
**Category:** Get Help\
**Created:** [November 27, 2021, 9:32am UTC](https://community.auth0.com/t/rtk-query-and-auth0/73851 "2021-11-27T09:32:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dln](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dln/32/33300_2.png) [@dln](https://community.auth0.com/u/dln)\
**Post date:** [November 27, 2021, 9:32am UTC](https://community.auth0.com/t/rtk-query-and-auth0/73851/1 "2021-11-27T09:32:39Z")

</div>

Hi!

I’m trying to integrate auth0 in a react+typescript project using auth0-react. So far so good I’m able to login and logout.

However I’m a bit blocked on how to add the auth0 bearer token to the API requests using rtk query.

Digging a bit on it I found this issue: [Provide access to the underlying `auth0-spa-js` methods · Issue #266 · auth0/auth0-react · GitHub](https://github.com/auth0/auth0-react/issues/266)  
That lead me to this gist: [auth0-react-gettoken.md · GitHub](https://gist.github.com/adamjmcgrath/0ed6a04047aad16506ca24d85f1b2a5c)

All the information is for the Apollo client so I was wondering if anybody on the forum has any experience making rtk-query and auth0 working with auth0-react or point me to some resource/example that helps me getting this to work.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 29, 2021, 10:58pm UTC](https://community.auth0.com/t/rtk-query-and-auth0/73851/3 "2021-11-29T22:58:40Z")

</div>

Hi @dln,

Welcome to the Auth0 Community!

You should add the token as a header to the request. Like this

```auto
Authorization: Bearer <token>

```

I am not familiar with rtk-query, but they provide an example of adding a bearer token here:

> **[fetchBaseQuery | Redux Toolkit](https://redux-toolkit.js.org/rtk-query/api/fetchBaseQuery#setting-default-headers-on-requests)**
>
> RTK Query \> API: fetchBaseQuery reference

Hope that helps!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 20, 2022, 11:07pm UTC](https://community.auth0.com/t/rtk-query-and-auth0/73851/4 "2022-01-20T23:07:22Z")

</div>

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