Unable to get acces token via PHP SDK

Ready to post? :mag: First, try searching for your answer.
I can login with me PHP SDK application but the accesToken is opaque. I read you have to specify an audience to make it not opaque.

In first place I used this:

// Now instantiate the Auth0 class with our configuration:
$auth0 = new \Auth0\SDK\Auth0([
    'domain' => getenv('AUTH0_DOMAIN'),
    'clientId' => getenv('AUTH0_CLIENT_ID'),
    'clientSecret' => getenv('AUTH0_CLIENT_SECRET'),
    'cookieSecret' => getenv('AUTH0_COOKIE_SECRET'),
]);

Then I tried to specify the audience:

// Now instantiate the Auth0 class with our configuration:
$auth0 = new \Auth0\SDK\Auth0([
    'domain' => getenv('AUTH0_DOMAIN'),
    'clientId' => getenv('AUTH0_CLIENT_ID'),
    'clientSecret' => getenv('AUTH0_CLIENT_SECRET'),
    'cookieSecret' => getenv('AUTH0_COOKIE_SECRET'),
    'audience' => ['https://api.domain.com'],
]);

But my accesToken is still opaque? What do I wrong with specifying the audience? I have seen for React they use the authorizationParams but that also does not like a solution for my problem. At the specified API of the audience I authorized the application at the Machine to Machine tab.

Hi @ralphvn86 :wave: Your SDK configuration looks good, so sounds like it might be something misconfigured with the application settings in your Auth0 dashboard. Does the app have the client_credentials grant enabled?

I found it, because of problems with my Steampixel router I made separate pages for each endpoint (login, logout, callback) instead of using the router.

Of course, I had to add the audience parameter to all of these new $auth0 initializations. After I did it is exactly working as expected!

I am sorry, my reply I just posted was already typed last week and still on this page but apparently, I forgot to press the ‘Reply’ button.

Ah, gotcha! No problem at all, I’m glad you were able to get it working in the end! Thanks for letting us know!

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