Auth0 Home Blog Docs

Angular app calling PHP API - accessToken too short


#1

Hey,

I have a PHP API that is expecting a JWT access token passed via the Bearer header. It will then validate the user using the auth0/auth0-php library. If it’s valid it’ll perform some function and return data back to the caller.

The PHP Api is called from a SPA (Angular 1.x) app. I’ve followed the quickstart tutorial and the log in works, but the accessToken I get back is too short and is not a JWT. My code is:
angularAuth0Provider.init({
clientID: ‘123’,
domain: ‘mydomain.com’,
responseType: ‘token id_token’,
audience: ‘https://mydomain.com/userinfo’,
redirectUri: ‘http://localhost/callback’,
scope: ‘openid profile email’
});

And then I direct the user to the login page via:
angularAuth0.authorize();

How can I get a JWT access token that can be used as the authorisation bearer for the API? My question is similar to this post, but none of the solutions worked for me: https://community.auth0.com/t/angular-spa-get-access-token-to-call-api

Thanks!