Mobile + api: React Native implementation

Hello everybody, I’m trying to follow mobile + api tutorial but I have a problem with the api part because it always gives me this error: “UnauthorizedError: jwt malformed”
This is the login part:
const auth0 = new Auth0({ domain: ‘’, clientId: ‘’ });
.authorize({scope: ‘openid profile email offline_access’, audience: ‘’})
.then(credentials => {…}).catch(…);

This is the part where I call my api:
AsyncStorage.getItem(‘accessToken’).then((ACCESS_TOKEN) => {
fetch(’’, {
method: ‘POST’,
headers: {
Accept: ‘application/json’,
‘Authorization’: 'Bearer '+ACCESS_TOKEN.token,
‘Content-Type’: ‘application/json’,
body: JSON.stringify({
data: data,
}).then(responseJson => {
}).catch(error =>
This is my auth module:
const jwt = require(‘express-jwt’);
const jwksRsa = require(‘jwks-rsa’);

const checkJwt = jwt({
    secret: jwksRsa.expressJwtSecret({
      cache: true,
      rateLimit: true,
      jwksRequestsPerMinute: 5,
      jwksUri: 'https://<my auth0 domain>'
    audience: "<api audience>",
    issuer: 'https://<my auth0 domain>',
    algorithms: ['RS256']

module.exports = checkJwt;

This are my endpoints:
const jwtAuthz = require(‘express-jwt-authz’);
const checkJwt = require(’…/…/auth’);
const v0 = require(‘express’).Router();
const <endpoint 1> = require(’./<endpoint 1>’);
const <endpoint 2> = require(’./<endpoint 2>’);
const <endpoint 3> = require(’./<endpoint 3>’);'/<endpoint 1>', checkJwt, jwtAuthz(['<scope 1>']), <endpoint 1>);'/<endpoint 2>', checkJwt, /*jwtAuthz(['<scope 2>']),*/ <endpoint 2>);'/<endpoint 3> checkJwt, jwtAuthz(['<scope 3>']), <endpoint 3>);

v0.get('/', (req, res) => res.status(200).json({message: 'working!'}))

module.exports = v0;

Thank you in advance for your attention.

1 Like

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?