parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

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

Open maruthi-wal opened this issue 10 years ago • 10 comments

maruthi-wal avatar Mar 01 '16 13:03 maruthi-wal

Hello Everyone,

Iam getting Master key is invalid, you should only use master key to send push

Please find my cloud code below:

Parse.initialize("appid", "javascriptkey", "masterkey"); var pushQuery = new Parse.Query(Parse.Installation); Parse.Push.send({

    channels: [ "Giants" ],
    data: {
        alert: "The Giants Mets 2-3."
    }
}, { useMasterKey: true });

My index.js code var api = new ParseServer({ databaseURI: databaseUri, cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js', appId: process.env.APP_ID, masterKey: process.env.MASTER_KEY, clientKey: process.env.CLIENT_KEY, restAPIKey: process.env.REST_API_KEY, fileKey: process.env.FILE_KEY, serverURL: 'http://IP/parse', push: { ios: [ { pfx: __dirname + '/name.p12', // Prod PFX or P12 bundleId: id',

production: false // Prod }, { pfx: __dirname + '/name.p12', // Prod PFX or P12 bundleId: 'id',

production: true // Prod } ]

} }); Please help me on this Thanks,

maruthi-wal avatar Mar 01 '16 13:03 maruthi-wal

Did you set your master key in the environment before starting your server? with: APP_ID=appid MASTER_KEY=masterKey node index.js

flovilmart avatar Mar 01 '16 16:03 flovilmart

Yes.. Master key and App Id i given.. Please help me on this..

maruthi-wal avatar Mar 01 '16 17:03 maruthi-wal

Pass the third argument as "true" to .send function.

mithleshjs avatar Mar 01 '16 22:03 mithleshjs

Its working for me. Thanks a lot for your suggestions.

My cloude code finally:

Parse.Push.send({ channels: ['Giants'], data: { alert: 'The Giants Mets 2-3.', badge: 1, sound: 'default' } }, { success: function() { console.log('##### PUSH OK'); }, error: function(error) { console.log('##### PUSH ERROR'); }, useMasterKey: true });

maruthi-wal avatar Mar 02 '16 10:03 maruthi-wal

@maruthi-wal Did you still have to call Parse.initialize("appid", "javascriptkey", "masterkey");in the body of your cloud code function?

If you did, did you just copied and pasted the keys in as strings?

AlecKriebel avatar Mar 02 '16 20:03 AlecKriebel

@AlecKriebel Thanks. Its working for me..

maruthi-wal avatar Mar 03 '16 04:03 maruthi-wal

@maruthi-wal It is not working for me. Did you still have the initialize call in your Cloud Code. I may need to add it to mine.

Thanks.

AlecKriebel avatar Mar 03 '16 04:03 AlecKriebel

@AlecKriebel Yep.. I added Parse.initialize("appid", "javascriptkey", "masterkey"); in my cloud code.

Make sure in index.js as below: push: { ios: [ { pfx: __dirname + '/name.p12', // Prod PFX or P12 bundleId: 'id',

production: false } ] }

Production should be false for testing.

maruthi-wal avatar Mar 03 '16 06:03 maruthi-wal

{ params: { id: '45J1QIaKIi' }, master: false, user: { _objCount: 0, className: '_User', id: '45J1QIaKIi' }, installationId: '82e1d517-7aac-d887-d02b-e407c3de5e7f' }

PUSH OK

APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected

how to solve this problem when I send push it performs success but the it also shows these in the console.

mahabubakram avatar Mar 04 '16 15:03 mahabubakram