Parse-sdk-js: Anonymous users are unsupported

Created on 4 Feb 2018  路  2Comments  路  Source: parse-community/Parse-SDK-JS

I'm trying to create an anonymous user with the SDK though get an error returned when trying to do so that they are unsupported:

error: Error generating response. ParseError {
  code: 252,
  message: 'This authentication method is unsupported.' } code=252, message=This authentication method is unsupported.

Code is as follows:

var Parse = require('parse/node');
var uuidv1 = require('uuid/v1');

var authData = {
  "authData": {
    "anonymous": {
      "id": uuidv1()
    }
  }
};
var user = new Parse.User();

user._linkWith("anonymous", authData).then(function(user) {
// then does not run. Parse.Error is thrown.
}

uuidv1() generates a unique UUID

Parse server setup is as follows:

    // Server
    var api = new ParseServer({
        databaseURI: 'mongodb://localhost:27017/parse',
        appId: parseAppID,
        masterKey: PARSE_MASTER_KEY,
        serverURL: parseServerURL,
        auth: {
            "spotify": {},
            "anonymous": {}
        }
    });

Spotify is my other auth type I am using, which is working fine.

  "dependencies": {
    "express": "^4.16.2",
    "parse": "^1.11.0",
    "parse-server": "^2.7.2",
    "uuid": "^3.2.1"
  }

Environment Setup

parse-server version: 2.7.2
Operating System: MacOS High Sierra
Hardware: MBP 15", Late 2016
MongoDB version: 3.6.2
Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost

resolved

Most helpful comment

Solved my own issue actually. Just my own lazy code writing! Accidentally wrote in "anonymous" within the authData. Solution for anybody who views this issue is to write anonymous authData as follows:

var authData = {
  "authData": {
    "id": uuidv1()
  }
};

var user = new Parse.User();

user._linkWith("anonymous", authData).then(function(user) { // Do something }

All 2 comments

Solved my own issue actually. Just my own lazy code writing! Accidentally wrote in "anonymous" within the authData. Solution for anybody who views this issue is to write anonymous authData as follows:

var authData = {
  "authData": {
    "id": uuidv1()
  }
};

var user = new Parse.User();

user._linkWith("anonymous", authData).then(function(user) { // Do something }

@harryjamesuk Thank you. I think the way from official document is wrong.

as http://docs.parseplatform.org/js/guide/#anonymous-user-authdata

let myAuthData = {
  "id": "12345678",
  "screen_name": "ParseIt",
  "consumer_key": "SaMpLeId3X7eLjjLgWEw",
  "consumer_secret": "SaMpLew55QbMR0vTdtOACfPXa5UdO2THX1JrxZ9s3c",
  "auth_token": "12345678-SaMpLeTuo3m2avZxh5cjJmIrAfx4ZYyamdofM7IjU",
  "auth_token_secret": "SaMpLeEb13SpRzQ4DAIzutEkCE2LBIm2ZQDsP3WUU"
}
let user = new Parse.User();
user._linkWith('twitter', myAuthData).then(function(user){
    // user
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlnquere picture jlnquere  路  4Comments

anhhtz picture anhhtz  路  3Comments

oallouch picture oallouch  路  4Comments

bezi picture bezi  路  4Comments

ryanemax picture ryanemax  路  7Comments