Skip to content

GCM error 401 when sending a push via adapter #35

Closed
@DeDuckProject

Description

@DeDuckProject

Edit: I solved it as follows:
Apparently GCM changed the way you create API keys. They no longer let you choose between server, browser, etc.. But I think their default doesn't whitelist all IPs so once I explicitly added my local public IP and my server's public IP I stopped getting this error.

Hi,
I'm trying to send a push using the default GCM adapter.
I get an 401 error.
My server config is configured ok, I know this because the correct apiKey is used when needed in the adapter (when I'm debugging).

What I find strange, is that in no place, the senderId is used

on init this code is executed:

function GCM(args) {
  if ((typeof args === 'undefined' ? 'undefined' : _typeof(args)) !== 'object' || !args.apiKey) {
    throw new _parse2.default.Error(_parse2.default.Error.PUSH_MISCONFIGURED, 'GCM Configuration is invalid');
  }
  this.sender = new _nodeGcm2.default.Sender(args.apiKey);
}

args holdes the proper apiKey and senderId but the senderId is disregarded and the this.sender only takes the apiKey. I've not found any code use for senderId.

I'm running parse-server version 2.2.17

note that I've noticed that google API changed their API key usage a bit, and not instead of choosing between ios,server, browser or android - the default is simply creating a non-restricted API key, which is what I did.
Triple checked the API key, and generated new ones and tried them as well...
Waited 5 minutes.
and then that 401 error.

Anyone have a clue or direction?

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