Skip to content

Master key is invalid, you should only use master key to send push  #601

Closed

Description

@topwebtek7

Hello,
To fix this issue, I have checked #575, #564, #401 and #396, but I could not find the resolution.

Here is my code:

main.js

Parse.Cloud.define("SendPush", function(request, response) {

    console.log(request.params);

    var receiveUser = new Parse.User();
    receiveUser.id = request.params.receiveUserId

    var query = new Parse.Query(Parse.Installation);
    query.equalTo('user', receiveUser);

    Parse.Push.send({

        where: query,
        data: {

            alert: request.params.alert,
            user_id: request.params.user_id,
            type: request.params.type
        }
    }, {
        success: function() {
            console.log('##### PUSH OK');
            response.success("Push Sent");
        },
        error: function(error) {
            console.log('##### PUSH ERROR: ' + error.message);
            response.error("Push Failed");
        },
        userMasterKey: true

    });
});

index.js

var api = new ParseServer({

  databaseURI: databaseUri || 'mongodb://...',

  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',

  appId: process.env.APP_ID || '',      

  masterKey: process.env.MASTER_KEY || '',

  fileKey: process.env.FILE_KEY || '',

  serverURL: 'http://localhost:1337/parse',

  filesAdapter: new S3Adapter(
    ...
  ),

  push: {

    android: {

      senderId: '',
      apiKey: ''
    },

    ios: [
      {
        pfx: __dirname + '/Certificates/Push_Sandbox.p12',
        bundleId: '',
        production: false
      },
      {
        pfx: __dirname + '/Certificates/Push_Production.p12',
        bundleId: '',
        production: true
      }
    ]
  }

});

When calling this on client app(iOS version), I get error message on my terminal.
##### PUSH ERROR: Master key is invalid, you should only use master key to send push
I am testing on my mac.

If you have the another resolution, please let me know about it.

Thanks,

Martin

Activity

  1. flovilmart commented on Feb 23, 2016

    @flovilmart
    Contributor

    Push is disabled by default on the client IHMO, as it's unsafe to open the push API to the clients. Maybe we could lift that restriction but I would not encourage it. @drew-gross what do you think?

  2. drew-gross commented on Feb 23, 2016

    @drew-gross
    Contributor

    I generally would like to prioritize compatibility with Parse.com, despite the security issues. It is possible (although difficult) to securely enable client push if your other security settings are on-point, not to mention the many clients already in the wild that rely on client push. I certainly wouldn't recommend new apps use client push, and I'd probably make sure there are lots of warnings if client push is enabled. At any rate, nobody is currently implementing it.

    @otto1020 your issue is that you misspelled useMasterKey (you have use*r*MasterKey)

  3. topwebtek7 commented on Feb 24, 2016

    @topwebtek7
    Author

    Thanks a lot. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions