You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _includes/rest/users.md
+58-10
Original file line number
Diff line number
Diff line change
@@ -111,7 +111,7 @@ There are three `emailVerified` states to consider:
111
111
2.`false` - at the time the `User` object was last refreshed, the user had not confirmed his or her email address. If `emailVerified` is `false`, consider refreshing the `User` object.
112
112
3._missing_ - the `User` was created when email verification was off or the `User` does not have an `email`.
113
113
114
-
You can request a verification email to be sent by sending a POST request to <codeclass="highlighter-rouge"><spanclass="custom-parse-server-mount">/parse/</span>verificationEmailRequest</code> with `email` in the body of the request:
114
+
You can request a verification email to be sent by sending a POST request to <codeclass="highlighter-rouge"><spanclass="custom-parse-server-mount">/parse/</span>verificationEmailRequest</code> with `email` in the body of the request:
115
115
116
116
<divclass="language-toggle">
117
117
<pre><codeclass="bash">
@@ -171,7 +171,6 @@ print result
171
171
172
172
If successful, the response body is an empty JSON object.
173
173
174
-
175
174
## Retrieving Users
176
175
177
176
You can also retrieve the contents of a user object by sending a GET request to the URL returned in the location header when it was created. For example, to retrieve the user created above:
@@ -234,7 +233,7 @@ print result
234
233
</code></pre>
235
234
</div>
236
235
237
-
The response matches the JSON object above for retrieving users. If the session token is not valid, an error object is returned:
236
+
The response matches the JSON object above for retrieving users. If the session token is not valid, an error object is returned:
238
237
239
238
```json
240
239
{
@@ -335,7 +334,6 @@ The return value is a JSON object that contains a `results` field with a JSON ar
335
334
336
335
All of the options for queries that work for regular objects also work for user objects, so check the section on [Querying Objects](#basic-queries) for more details.
337
336
338
-
339
337
## Deleting Users
340
338
341
339
To delete a user from the Parse Cloud, send a DELETE request to its URL. You must provide the `X-Parse-Session-Token` header to authenticate. For example:
@@ -366,7 +364,7 @@ print result
366
364
367
365
Parse allows you to link your users with services like Twitter and Facebook, enabling your users to sign up or log into your application using their existing identities. This is accomplished through the sign-up and update REST endpoints by providing authentication data for the service you wish to link to a user in the `authData` field. Once your user is associated with a service, the `authData` for the service will be stored with the user and is retrievable by logging in.
368
366
369
-
`authData` is a JSON object with keys for each linked service containing the data below. In each case, you are responsible for completing the authentication flow (e.g. OAuth 1.0a) to obtain the information the the service requires for linking.
367
+
`authData` is a JSON object with keys for each linked service containing the data below. In each case, you are responsible for completing the authentication flow (e.g. OAuth 1.0a) to obtain the information the the service requires for linking.
370
368
371
369
### Facebook `authData`
372
370
@@ -411,7 +409,7 @@ Learn more about [Twitter login](https://dev.twitter.com/docs/auth/implementing-
411
409
412
410
### Signing Up and Logging In
413
411
414
-
Signing a user up with a linked service and logging them in with that service uses the same POST request, in which the `authData` for the user is specified. For example, to sign up or log in with a user's Twitter account:
412
+
Signing a user up with a linked service and logging them in with that service uses the same POST request, in which the `authData` for the user is specified. For example, to sign up or log in with a user's Twitter account:
415
413
416
414
<divclass="language-toggle">
417
415
<pre><codeclass="bash">
@@ -460,7 +458,7 @@ print result
460
458
</code></pre>
461
459
</div>
462
460
463
-
Parse then verifies that the provided `authData` is valid and checks to see if a user is already associated with this data. If so, it returns a status code of `200 OK` and the details (including a `sessionToken` for the user):
461
+
Parse then verifies that the provided `authData` is valid and checks to see if a user is already associated with this data. If so, it returns a status code of `200 OK` and the details (including a `sessionToken` for the user):
The body of the response will contain the `objectId`, `createdAt`, `sessionToken`, and an automatically-generated unique `username`. For example:
497
+
The body of the response will contain the `objectId`, `createdAt`, `sessionToken`, and an automatically-generated unique `username`. For example:
500
498
501
499
```json
502
500
{
@@ -509,7 +507,7 @@ The body of the response will contain the `objectId`, `createdAt`, `sessionToken
509
507
510
508
### Linking
511
509
512
-
Linking an existing user with a service like Facebook or Twitter uses a PUT request to associate `authData` with the user. For example, linking a user with a Facebook account would use a request like this:
510
+
Linking an existing user with a service like Facebook or Twitter uses a PUT request to associate `authData` with the user. For example, linking a user with a Facebook account would use a request like this:
513
511
514
512
<divclass="language-toggle">
515
513
<pre><codeclass="bash">
@@ -556,7 +554,7 @@ After linking your user to a service, you can authenticate them using matching `
556
554
557
555
### Unlinking
558
556
559
-
Unlinking an existing user with a service also uses a PUT request to clear `authData` from the user by setting the `authData` for the service to `null`. For example, unlinking a user with a Facebook account would use a request like this:
557
+
Unlinking an existing user with a service also uses a PUT request to clear `authData` from the user by setting the `authData` for the service to `null`. For example, unlinking a user with a Facebook account would use a request like this:
560
558
561
559
<divclass="language-toggle">
562
560
<pre><codeclass="bash">
@@ -613,3 +611,53 @@ For example, if you want the user with id `"3KmCvT7Zsb"` to have read and write
613
611
```
614
612
615
613
If you want to access your data ignoring all ACLs, you can use the master key provided on the Dashboard. Instead of the `X-Parse-REST-API-Key` header, set the `X-Parse-Master-Key` header. For backward compatibility, you can also do master-level authentication using HTTP Basic Auth, passing the application id as the username and the master key as the password. For security, the master key should not be distributed to end users, but if you are running code in a trusted environment, feel free to use the master key for authentication.
614
+
615
+
## Impersonating a user
616
+
617
+
An application may have use cases where an operator or automated system needs to
618
+
take action on a user's behalf, under the user's authority, without access to
619
+
the user's credentials. The Parse REST API supports these use cases with the
620
+
`/loginAs` endpoint. This endpoint takes a `userId` parameter, and must be
621
+
called using the master key. It will create a session for the given user ID, and
622
+
will return the same response format as the `/login` endpoint. The new session
623
+
will have a `createdWith` value of `create`, and an `authProvider` value of
624
+
`override`.
625
+
626
+
**The `/loginAs` endpoint performs no identity verification** - any client with
627
+
the master key can log in as any user. You are strongly encouraged to apply
628
+
careful security around any systems that call the `/loginAs` endpoint.
0 commit comments