Skip to content

Commit df82987

Browse files
committed
Small fix on clients creation api and added user creation example
1 parent 517422b commit df82987

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
if (isset($_REQUEST['create'])) {
4+
5+
$app_token = getenv('AUTH0_APPTOKEN');
6+
$domain = getenv('AUTH0_DOMAIN');
7+
8+
$email = $_REQUEST['email'];
9+
$password = $_REQUEST['password'];
10+
$color = $_REQUEST['color'];
11+
12+
echo '<pre>';
13+
var_dump(\Auth0\SDK\API\ApiUsers::create($domain, $app_token, array(
14+
'email' => $email,
15+
'password' => $password,
16+
'connection' => 'Username-Password-Authentication',
17+
'user_metadata' => array(
18+
'color' => $color,
19+
)
20+
)));
21+
echo '</pre>';
22+
}
23+
?>
24+
25+
26+
<form action="?create-user" method="POST">
27+
28+
<label for="email">Email</label>
29+
<input type="email" name="email" id="email" />
30+
31+
<label for="password">Password</label>
32+
<input type="password" name="password" id="password" />
33+
34+
<label for="color">Color</label>
35+
<input type="color" name="color" id="color" />
36+
37+
<input type="submit" name="create" value="Create" />
38+
39+
</form>

examples/basic-oauth/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222

2323
if (isset($_REQUEST['update-metadata'])) require 'update-metadata.php';
2424

25+
if (isset($_REQUEST['create-user'])) {
26+
require 'create_user.php';
27+
exit;
28+
}
29+
30+
2531
if ($userInfo) require 'logeduser.php';
2632

2733

examples/basic-oauth/logeduser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<a href="?logout">Logout</a>
22
<a href="?update-metadata">Update Metadata</a>
3+
<a href="?create-user">Create User</a>
34

45

56
<?php

src/API/ApiClients.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ public static function create($domain, $token, $data) {
7373

7474
$info = self::getApiV2Client($domain, $token)->post()
7575
->clients()
76+
->withHeader(new AuthorizationBearer($token))
7677
->withHeader(new ContentType('application/json'))
7778
->withBody(json_encode($data))
78-
->call();
79+
->dump();
7980

8081
return $info;
8182
}

0 commit comments

Comments
 (0)