Subscriber get returning a 401


When I test the /subscribers/{app_user_id} endpoint on the API reference page using my public key, I get a 200 response.

However, when I run the same code from my Node cloud function, I consistently get back a 401.

Any ideas as to why this is? 


Best answer by David Krebs 3 May 2022, 15:39

View original

3 replies

Userlevel 5
Badge +9

Can you share the error message you’re getting along with the 401? Are you authenticating correctly with the authorization header and `Bearer <YOUR_API_KEY>`


Yes, certainly.

I am setting the Authorization header with my api key using the “Bearer <API_KEY>” format.

Also, I checked the url, and it’s good.

When I print the error object, I get a status of “401” and a statusText of “Unauthorized”.

What is returned is the following object:

{ timeout: 0, size: 0 }



I discovered a workaround.


This code gives me the 401

const sdk = require('api')('@revenuecat/v4.0#fawmbsl21aqc0w');

app_user_id: 'app_user_id',
Authorization: 'Bearer <API_KEY>'
.then(res => console.log(res))
.catch(err => console.error(err));


If I instead use axios, I get the happy response

const axe = axios.create({
baseURL: '',
headers: {
'Authorization': 'Bearer <API_KEY>'

.then((response) => console.log(
.catch(() => console.log(e));