Parse-server: Anonymous users via REST API?

Created on 25 Jul 2016  路  2Comments  路  Source: parse-community/parse-server

I'm a little confused about the functionality in Parse Server that talks about anonymous users. I see it referenced in the source code here: https://github.com/ParsePlatform/parse-server/blob/fcfe2a0376658279b2a6df3346c8ab036c977252/src/authDataManager/index.js#L41

I don't really know how to create an anonymous user JUST via the REST API. Is that possible?

Most helpful comment

For others coming to this issue, I found that you can create an anonymous user via the REST API by posting to the /users collection a payload like:

{
    "authData": {
        "anonymous": {
            "id": "abcdef1234"
        }
    }
}

Response will look like this if this anonymous user hasn't been created before:

{
  "objectId": "ednSJrFWjz",
  "createdAt": "2016-07-26T19:46:43.321Z",
  "username": "nbIuF9d2xnHYLKcUxUbQg5MIF",
  "sessionToken": "r:cf21ab1e1e4a3090dae85068be2ca19f"
}

And it will look like this if the user has already been created previously:

{
  "objectId": "ednSJrFWjz",
  "username": "nbIuF9d2xnHYLKcUxUbQg5MIF",
  "authData": {
    "anonymous": {
      "id": "abcdef1234"
    }
  },
  "createdAt": "2016-07-26T19:46:43.321Z",
  "updatedAt": "2016-07-26T19:46:43.321Z",
  "ACL": {
    "*": {
      "read": true
    },
    "ednSJrFWjz": {
      "read": true,
      "write": true
    }
  },
  "sessionToken": "r:c3fe195eac911fcf9cc2f9758cac3d66"
}

All 2 comments

The Parse SDKs all use the REST API to manage anonymous users. They are open source, so looking into their implementation might be the best way to learn how to do this through the REST API yourself.

I'll close this since it is not about any issue with Parse Server itself.


You may use Server Fault for questions about managing Parse Server.

For code-level and/or implementation-related questions or technical support, please refer to Stack Overflow.

For others coming to this issue, I found that you can create an anonymous user via the REST API by posting to the /users collection a payload like:

{
    "authData": {
        "anonymous": {
            "id": "abcdef1234"
        }
    }
}

Response will look like this if this anonymous user hasn't been created before:

{
  "objectId": "ednSJrFWjz",
  "createdAt": "2016-07-26T19:46:43.321Z",
  "username": "nbIuF9d2xnHYLKcUxUbQg5MIF",
  "sessionToken": "r:cf21ab1e1e4a3090dae85068be2ca19f"
}

And it will look like this if the user has already been created previously:

{
  "objectId": "ednSJrFWjz",
  "username": "nbIuF9d2xnHYLKcUxUbQg5MIF",
  "authData": {
    "anonymous": {
      "id": "abcdef1234"
    }
  },
  "createdAt": "2016-07-26T19:46:43.321Z",
  "updatedAt": "2016-07-26T19:46:43.321Z",
  "ACL": {
    "*": {
      "read": true
    },
    "ednSJrFWjz": {
      "read": true,
      "write": true
    }
  },
  "sessionToken": "r:c3fe195eac911fcf9cc2f9758cac3d66"
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

LtrDan picture LtrDan  路  4Comments

carjo422 picture carjo422  路  3Comments

mohmagdy picture mohmagdy  路  3Comments

dcdspace picture dcdspace  路  3Comments

shardul08 picture shardul08  路  3Comments