# Unable to get acces token via PHP SDK

**URL:** <https://community.auth0.com/t/unable-to-get-acces-token-via-php-sdk/137921>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-php\
**Created:** [July 2, 2024, 1:41pm UTC](https://community.auth0.com/t/unable-to-get-acces-token-via-php-sdk/137921 "2024-07-02T13:41:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphvn86](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ralphvn86](https://community.auth0.com/u/ralphvn86)\
**Post date:** [July 2, 2024, 1:41pm UTC](https://community.auth0.com/t/unable-to-get-acces-token-via-php-sdk/137921/1 "2024-07-02T13:41:20Z")

</div>

Ready to post? 🔍 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:

```auto
// 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:

```auto
// 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.

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [July 8, 2024, 10:52pm UTC](https://community.auth0.com/t/unable-to-get-acces-token-via-php-sdk/137921/2 "2024-07-08T22:52:20Z")

</div>

Hi @ralphvn86 👋 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?

---

<div class="post-metadata">

**Author:** ![ralphvn86](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ralphvn86](https://community.auth0.com/u/ralphvn86)\
**Post date:** [July 9, 2024, 8:19am UTC](https://community.auth0.com/t/unable-to-get-acces-token-via-php-sdk/137921/3 "2024-07-09T08:19:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![ralphvn86](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ralphvn86](https://community.auth0.com/u/ralphvn86)\
**Post date:** [July 9, 2024, 8:21am UTC](https://community.auth0.com/t/unable-to-get-acces-token-via-php-sdk/137921/5 "2024-07-09T08:21:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [July 9, 2024, 3:25pm UTC](https://community.auth0.com/t/unable-to-get-acces-token-via-php-sdk/137921/6 "2024-07-09T15:25:50Z")

</div>

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

---

<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:** [July 23, 2024, 3:26pm UTC](https://community.auth0.com/t/unable-to-get-acces-token-via-php-sdk/137921/7 "2024-07-23T15:26:08Z")

</div>

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