PHP/Laravel Management API Instance (Access Token)

Hello everyone.

I am using Auth0 in my laravel project. Meaning that I’m using the Auth0-Laravel SDK from here.

On my multipage Website, I want to give the user the ability to create, edit, show and delete users from auth0. After some research, I’ve found out, that this is possible by using the Manager Endpoint, which is a connection to the Management API, which has all the functions I need.

Heres the problem: I havent found out how to use a manager instance in laravel. The only thing I found online is with cURL, but inside of the Auth0 SDK there seems to be a ManagerEndpoint class and an Action class, which both have getAll() methods and stuff that I want to use.

So is there any easier way to do that? Or do I have to go with cURL? And If I have to do it with cURL, how do I get the Access Token for my API? Thats something I couldn’t figure out as well.
Doing Auth::getSession() and printing it, I see that there is a auth0 session token, but I cant save it into a variable and I’m not even sure if that would be the best approach.

THX!

Hi @LozziStyle,

I’m going to reach out to our team on this and I’ll get back to you. Thanks!

1 Like

Here’s is what the maintainer said:

Since the Laravel SDK is built on top of the PHP SDK, it inherits all that good stuff from in there. Here’s how you can access the Management API through the Laravel SDK:

app('auth0')->getSdk()->management();

So, for example, to update a user:

app('auth0') // Gets the Laravel SDK
  ->getSdk() // Gets the underlying PHP SDK
  ->management() // Gets the Management API from the PHP SDK
  ->users() // Gets the Users endpoint from the Management API
  ->update( // PATCH /api/v2/users/{id}, see: https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id
    id: 'auth0|8675309',
    body: ['user_metadata' => ['favorite_color' => 'blue']]
  );
1 Like

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