Logging out a logged user through the Parse GraphQL API
Problem
You want to log out a logged user in your backend through the Parse GraphQL API.
Solution
Using the Parse GraphQL API, you can log out a logged user just by sending the user’s sessionToken
through the X-Parse-Session-Token
header (as described in the authenticating a user recipe) and calling the logOut
mutation. Parse Server will destroy the sessionToken
and it will not be accepted for any other future request.
Depending on the version of Parse you choose to run, the GraphQL queries, mutations and results will be slightly different.
Please choose the correct example along with the Parse version you are running.
The headers for this operation are X-Parse-Application-Id
, X-Parse-Client-Key
and X-Parse-Session-Token
1
2
3
4
5
| mutation logOutButton {
logOut(input: { clientMutationId: "9vc3NljYHP" }) {
clientMutationId
}
}
|
Result Parse 4.4.0 and later:
1
2
3
4
5
6
7
8
| {
"data": {
"logOut": {
"clientMutationId": "9vc3NljYHP"
}
}
}
|
With Parse 3.10.0 and 4.2.0 you must set a header called X-Parse-Session-Token
containing the Session Token for the authenticated user. Once it is set, you can call:
1
2
3
4
5
6
7
8
9
| mutation{
logOut(input: { clientMutationId: "sampleId"}){
viewer{
user{
id
}
}
}
}
|
Result Parse 3.10.0 and 4.2.0:
1
2
3
4
5
6
7
8
9
10
11
| {
"data": {
"logOut": {
"viewer": {
"user": {
"id": "X1VzZXI6UHNOUkJ3Y1YyRQ=="
}
}
}
}
}
|
With Parse 3.9.0 you must set a header called X-Parse-Session-Token
containing the Session Token for the authenticated user. Once it is set, you can call:
1
2
3
4
5
| mutation{
logOut{
id
}
}
|
Result Parse 3.9.0:
1
2
3
4
5
6
7
| {
"data": {
"logOut": {
"id": "Gx2zW7yEnY"
}
}
}
|
1
2
3
4
5
| mutation{
logOut{
objectId
}
}
|
Result Parse 3.8.0:
1
2
3
4
5
6
7
| {
"data": {
"logOut": {
"objectId": "KTznKVzto2"
}
}
}
|
1
2
3
4
5
| mutation LogOut {
users {
logOut
}
}
|
Result Parse 3.7.2:
1
2
3
4
5
6
7
| {
"data": {
"users": {
"logOut": true
}
}
}
|