Http request to google cloud messaging - unauthorized error


#1

Hello, Im trying to do a http request for push notification. Below is my code,

     var req = {
        method: 'POST',
        url: 'https://gcm-http.googleapis.com/gcm/send',

        headers: {
            'Content-Type': 'application/json',
                'Authorization': apiKey
        },
        body: JSON.stringify({
	        'to' : deviceToken,
	        "data": {
	          "title": "fdsafdsa",
	          "message": "gdsa"
        	}
        })
    };

   $http(req).success(function(resp){
 	
      console.log("Push success", resp);
    }).error(function(error){
     
      console.log("Push error", error);
    });

As the title suggest, the request isn’t going through and am getting an unauthorized error. Any help would be greatly appreciated.