Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Key Issues #159

Closed
calhouncole opened this issue Feb 2, 2016 · 5 comments · May be fixed by UbuntuEvangelist/parse-server#13
Closed

Client Key Issues #159

calhouncole opened this issue Feb 2, 2016 · 5 comments · May be fixed by UbuntuEvangelist/parse-server#13

Comments

@calhouncole
Copy link

I'm currently working with two clients: JavaScript and an iOS app.

The JavaScript client will only connect if I don't have a client key defined upon setup:

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: 'myAppId',
  // clientKey: 'clientKey',
  masterKey: process.env.MASTER_KEY || 'myMasterKey'
});

The initialization and query of Parse in my Javascript is:

   Parse.initialize('myAppId');
    Parse.serverURL = 'http://localhost:1337/parse';
    var Purchased_Tickets = Parse.Object.extend("GameScore");
    var query = new Parse.Query(Purchased_Tickets);
    query.find({
      success: function(games) {
        for (var i = 0; i < games.length; ++i) {
          console.log(games[i].get('score'));

      }
      console.log("THE COUNT = ");
      console.log(games.length);
      res.send(games.length);
    }
  });

If I include the client key in the initialization of the parse server and my query -- I get a 403 (authorization error).

The iOS SDK requires the clientKey upon initialization or else it will not build. Because of this, I'm not able to connect both of my clients to the same ParseServer. Any suggestions?

@christianmarth
Copy link

This is how I initiate my JS Client and it seems to work for JS and iOS

    Parse.initialize("myAppId","myJavaScriptKey");
    Parse.serverURL = 'http://localhost:1337/parse';

Make sure you're using the javascriptKey, not the clientKey for JS

https://parse.com/docs/js/api/classes/Parse.html#methods_initialize

@gfosco
Copy link
Contributor

gfosco commented Feb 2, 2016

The best option is to not set any client keys in parse-server. They are not necessary and do not increase security. The issue here is that if you define any client keys (rest, client, js) then all requests must provide a valid key. So, if you had defined a client key, but not a Javascript key, that's why your JS calls failed.

@calhouncole
Copy link
Author

Thanks for the tip. I've initialized my parse server without a client key.

Because one is required in the iOS SDK, I've just initialized it as 'unused':

        Parse.initializeWithConfiguration(ParseClientConfiguration(block: {(configuration: ParseMutableClientConfiguration) -> Void in
            configuration.applicationId = "appID"
            configuration.clientKey = "unused"
            configuration.server = "serverURL"
        }))

Everything seems to be working fine.

Appreciate the feedback!

@gfosco
Copy link
Contributor

gfosco commented Feb 2, 2016

👍

@arkangelx
Copy link

arkangelx commented Apr 21, 2016

I am having issues logging to the my version of the todoapp. below is the change i have made from Parse.initialize code block
Parse.initialize("xxxxx","xxxx");
Parse.serverURL = 'https://xxx-xxx-11111.herokuapp.com/parse/';
and I get unauthorised error message (not well-formed in the console log)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants