Why dose it return 401 using guzzle

I’m a Japanese.
So, maybe my English is so bad.
Sorry.


I want to use API of Auth0 about update user’s metadata.
=> https://auth0.com/docs/metadata/apis#update-user-metadata

However, this PHP’s sample written in cURL.
So I rewrite the sample to Guzzle.
However, the code I rewrite will return 401 error.
I am in trouble understanding this cause.

In fact, for POST and GET codes, 200 values will be returned.
I do not know if this cause is in Auth0 or in my code.
If you do not mind, would you mind checking out my code?

$data = [
    'form_params' => [
        'user_metadata' => ['addresses' => ['home' => '123 Main Street, Anytown, ST 12345']]
    ],
    'header' => [
        'content-type' => 'application/json',
        'Authorization' => 'Bearer ABCD'
    ],
];

$guzzleClient = new Client();
$res = guzzleClient->request('PATCH', 'https://YOUR_AUTH0_DOMAIN/api/v2/users/id_of_user', $data);

var_dump(res->getBody()->getContents());
# 401 returned
# {"statusCode":401,"error":"Unauthorized","message":"Missing authentication"}

Thank you.

Hey there @ntkt,

As it has been more than a few months since this topic was opened and there has been no reply or further information provided from the community as to the existence of the issue we would like to check if you are still facing the described challenge?

We are more than happy to assist in any way! If the issue is still out there please let us know so we can create a new thread for better visibility, otherwise we’ll close this one in week’s time.

Thank you!

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