Reputation: 563
I am trying to use auth0 api for php. I strated with this examples: enter link description here
Every time when I start I got error that I'm calling non-defined class in dotenv-autoloader (Dotenv::load(__DIR__);)
. I avoid this and I wrote manually parameter. After that I can create, delete user, change user_metadata, but I can't change app_matadata. Always got same error: {"statusCode":401,"error":"Unauthorized","message":"Missing authentication"}
Can someone help me with this issue?
Thanks.
Upvotes: 0
Views: 400
Reputation: 887
what error did you get with Dotenv?
3 things might happened:
composer.json
file) .env
file with the configuration.env
file had the wrong formatAnyway, if you set the configuration manually is enough.
About the app_metadata
how are you updating it?
this snippet should work:
require __DIR__ . '/vendor/autoload.php';
use Auth0\SDK\Auth0Api;
$token = "eyJhbGciO....eyJhdWQiOiI....1ZVDisdL...";
$domain = "account.auth0.com";
$user_id = 'auth0|123...';
$auth0Api = new Auth0Api($token, $domain);
$usersList = $auth0Api->users->update( $user_id, [ "app_metadata" => [ "some_attribute" => "some_value" ] ]);
var_dump($usersList);
One important thing, to update the app_metadata
you need an api token with the update:users_app_metadata
scope, you can't use the user token for it.
Upvotes: 2