Authorization Key and GCM Sender ID on Batch API - google-cloud-messaging

I'm trying to set up the Batch android api in order to send push notifications. On the instructions they mentioned, it has authorization key and gcm sender Key. But I have enabled only the google cloud messaging api and an api key.

You can follow this Google documentation on how to set up your GCM App on Android. You need to have a connection server that take messages from the application server and send them to the device. To send a message, the application server issues a POST request.
https://gcm-http.googleapis.com/gcm/send
A message request is made of 2 parts: HTTP header and HTTP body. The HTTP header must contain the following headers:
Authorization: key=YOUR_API_KEY
Content-Type: application/json for JSON; application/x-www-form-urlencoded;charset=UTF-8 for plain text. If Content-Type is omitted, the format is assumed to be plain text.
Example:
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data" : {
...
},
}
Based from this SO question:
According to updated Google docs, it seems that Project Number on Google API Console is used as SENDER ID
Here are the steps on how to get the Sender ID:
Open Google api console
Create project
Click on Left hand side menu icon
Click on Google cloud Platform
You would get SenderId from there.
Be noted that the Sender ID is the Project Number.
You can check in this tutorial on how to find Sender ID and API Key for GCM.
Hope this helps! :)

Related

SONOS auth token is not being sent in Authorization HTTP header for CQ API calls

I followed the Sonos docs for adding app authentication and the page for using authentication tokens and the result is that the SMAPI server correctly returns an authToken together with a privateKey back to the controller. I can see the authToken being present in the credentials header inside the SOAP messages sent to my SMAPI server.
However, despite the many mentions of this inside the Sonos docs pages related to HTTP requests (I will list the resources links down below), the same authToken is not being sent inside the HTTP header Authorization, this making my CQ server unable to validate requester identity.
I tried the following, without success:
checking "Requires authorization header" capability in the customsd page of my Sonos device (I tried this because the docs page about capabilities precisely indicates that checking this "Sends OAuth token in the HTTP Authorization header.")
identifying some correlation between the "X-Sonos-" prefix HTTP headers used when the controller sends SOAP messages to my SMAPI server and the "X-Sonos-" prefix HTTP headers used when the device sends HTTP requests to my CQ server (eventually, I could not find any information that would identify the user based on this)
From Sonos device:
X-Sonos-Playback-Id: RINCON_48??????D201400:3165321802 <= deviceId inserted after RINCON_
X-Sonos-Device-Id: Sonos_U????????????????????????6 <= householdId
X-Sonos-Corr-Id: 267e3e0c-75ca-4b9d-8be4-b8a795a462a3 <= unique each time
From macOS Controller:
X-Sonos-Controller-ID: 68:??:??:??:??:07 <= the same each time
X-Sonos-Api-Key: 8??????e-7??7-4??f-b??6-7??????????0 <= the same each time
X-Sonos-Corr-Id: 648ec896-e043-44f8-bfba-cd0a80c9d857 <= unique each time
checking both "Include SMAPI context headers with all requests" and "Include Zone Player IDs in credentials header" capabilities in the customsd page of my Sonos device (I tried this following the answer to this sonos tagged stackoverflow question Now that device ID is deprecated, is there another way to identify the client?)
The docs links I mentioned above that refer the presence of the auth token inside the HTTP Authorization header are the following:
the GET /context CQ API method page says to return 401 Unauthorized when "The access token has expired or is invalid."
the GET /itemWindows CQ API method page says "the player can use this API to obtain a new access token in the response from your cloud queue server" and "The request contains the access token in the authorization header" and "If the access token is set to expire soon, an updated one is included in the X-Updated-Authorization header of the response"
the POST /timePlayed CQ API method page says "The request header contains the access token in the authorization header" and that the method returns ERROR_SONOS_TOKEN_EXPIRED when "SMAPI OAuth token is expired, and user must re-authorize the account"
the GET /version CQ API method page says again that "The request contains the access token in the authorization header" and talks about a now deprecated updateToken parameter and also says that "If the access token is set to expire soon, you should include an updated token in the X-Updated-Authorization header."
But the most clear mention is in the page about HTTP requests, because it's not particular just for the CQ API endpoints but for all HTTP endpoints, even those hosted by the SMAPI server itself. The page reads the following 2 excerpts:
and
To conclude, with so many mentions of it in the official Sonos docs, why isn't this essential header being transmitted in the HTTP Authorization header? And how should a CQ verify the identity of the requester without the presence of this authToken on each API method request?
The auth token is sensitive information and will not be included in the HTTP headers if it's being sent to an endpoint that is insecure.
Try again with your CQ server behind an https:// address.
If I follow you correctly, the token is passed in the header under loginToken, see https://developer.sonos.com/build/content-service-add-features/add-authentication/use-authentication-tokens/
This is not an http header, this is a section of the SOAP envelope. Like this:

Authenticating to Monday.com API from Zapier

I am building a intergration in Zapier (not a ZAP) to retrive dat from Monday.com Monday uses an API key that is required to be passed in the header to authenticate requests.
In Zapier developer I have set up the authentication as API Key. I have set up a field api_key for the user to add their key.
I have set up the test get request and in the HTTP Headers tab have added the api_key
When I send the reqest authentication fails with the folloaing error
authentication failed: The app returned "Not Authenticated". What happened (You are seeing this because you are an admin): Stack trace: ResponseError: {"status":401,"headers":{"content-type":"application/json; charset=utf-8"},"content":"{"errors":["Not Authenticated"]}","request":{"url":"https://api.monday.com/v2?query=%7Bme%7B%7D%7D"}} at
The Authentication code is
I think the issue is that you are sending API key as api_token header.
You need to send this API key as "Authorization" header of your request to monday.com.
example

IBM API Connect - Security Set up Issue - API Key in the Header not working

We are working on hosting a REST API in APIC.
I am able to test the API using APIC endpoint by turning off the security. But when I enabled the security (using API Key) I am facing problem. In fact, I am able to pass the api key in the query and able to run GET operations successfully.
However, we really want to pass the API key (X-IBM-Client-Id) in the header for Authorization. when I pass the API key in the header, I get 500 Internal Server
Error (Headers:
content-type: text/xml; charset="utf-8" x-backside-transport: FAIL FAIL). *Any idea why I am not able to pass the client ID in the header successfully? *
When you are on the API Security Definition page, and the Type entry is API key, there is a drop-down list with a choice of 'Header' or 'Query'.
My guess is that you have chosen 'Query'. Change it to 'Header' and you should be OK.

Amazon Cloud Drive REST api endpoint

I am building a program that will list albums/folders and images from my Amazon Cloud Drive. I am able to authenticate and get a token by following the instructions here at amazon public apis.
I am having trouble with the next call to get my endpoints described here under Account API.
Using get
GET : {{metadataUrl}}/account/endpoint Gets the customer end-point against
which REST queries will be executed.
So my request looks just like this in fiddler and on my site just like it is described on the Amazon site here under Get Endpoint. The only differences is the token for obvious reasons.
Sample Request:
GET /drive/v1/account/endpoint HTTP/1.1
Host: drive.amazonaws.com
Authorization: Bearer
Atza|IQEBLjAsAhQ5zx7pKp9PCgCy6T1JkQjHHOEzpwIUQM
My response is:
{
"message":"Authorization header requires 'Credential' parameter.
Authorization header requires 'Signature' parameter.
Authorization header requires 'SignedHeaders' parameter.
Authorization header requires existence of either a 'X-Amz-Date'
or a 'Date' header. Authorization=Bearer"
}
What I am expecting:
{
"customerExists": true,
"contentUrl": "https://content-na.drive.amazonaws.com/cdproxy/",
"metadataUrl": "https://cdws.us-east-1.amazonaws.com/drive/v1/"
}
I did find some information about building the objects in my response from amazon, however, it's not listed in the documentation on the amazon developer site. Is this something new that has not been updated in the docs or am I doing something wrong?
I had a new line between Authorization: Bearer and my token Atza|IQEBLjAsAhQ5zx7pKp9PCgCy6T1JkQjHHOEzpwIUQM. After removing the new line my issue was fixed..

receiving an input file dynamically and put my mule application in listening

Scenario:
- An application want to send a push to a list of device.
- so she sends information to my mule application which must be listening to the arrived information.
- My application will send this information via web service to the application which will send the push and then my application will wait for a response which is a json file with content: success: 0/1 failed: 0/1,
- according to this answer my mule application will send email which i take from the database, if the device concerned didn't receive the push.
I have done the last part of this scenario. from the receipt of the answer of the push. Now I have some questions about the first part:
I guess that the application sends a json file that contains a list of information of each device.
How processed the list of information devices. I must loop on the contents of the json file. any example of this?
How to put my application in listening for the arrivals request for sending push?
is the http connector sufficient? if so how to configure the path variable.
I'm using mule 3.5.0 CE, Thank you in advance.
Lets break this down, to the various components:
Sender Application - this is the service that needs to communicate with the devices.
Device Controller - this is the application that talks to the hardware devices.
Proxy - this is what you are developing on the Mule ESB. It will connect to both the Sender Application, and the Device Controller and transfer the request from Sender to Controller; and then send the results from the Controller back to the Sender.
The flow would look something like this:
Sender Application needs to communicate with devices.
Sender Application transmits information using JSON.
Proxy receives this JSON request.
The Proxy then contacts the Device Controller over HTTP.
The Device Controller only talks to the Proxy, and returns a result of 0 or 1 depending on the result from the physical device.
The Proxy then needs to communicate this result to the Sender Application.
At first, you might think to develop your Proxy over HTTP (using the HTTP Connector). This connector creates a web service endpoint (a website, basically) that can listen and respond to requests.
The Sender Application connect to this endpoint over HTTP and submits the JSON document containing the commands to be executed.
Your proxy then immediately contact the Device Controller (again, over HTTP using the same connector).
The device controller talks to the devices, and then returns the response to your Proxy (over HTTP).
You take this response and then send it back as the response to the original HTTP request (from the Sender Application).
The problem here is if there is any delay between your connection and the Device Controller (or the Device Controller and the physical devices), the connection will remain blocked on both sides (since you need to send a response).
If there is a large delay the HTTP connection between your Proxy and Sender Application may terminate.
This is the same when some site is overloaded and doesn't respond - eventually the browser will timeout.
To avoid this scenario, split your integration into three separate flows.
The first flow will create a normal HTTP connection to which the Sender Application will upload the JSON document. It will take the JSON document and convert each entry into a message using the batch module (note: this is only available in the Enterprise edition - for the CE version you'll have to code this logic yourself). Next, take this message and put them in a separate queue. Return the unique ID of this message as a JSON response back to the Sender Application.
Your second flow is listening on this queue and whenever a message arrives, it connects to the Device Controller and gets the response. The response is then written to another queue.
Your third and final flow listens on this results queue, takes each message on this queue and converts it to JSON/XML. It then has a HTTP connector where it can be queried for results for each command.
In the above setup, your Sender Application can drop a large JSON file of commands to be executed; for each command, a unique ID will be returned to the Sender Application.
It will then query the result endpoint (what your last flow exposes) and send it the message ID. The result endpoint will then check the status of this request and respond with the appropriate code.
Here is an example of how this would work (from the point of view of the Sender Application):
I is the input to your flow, O is the result sent.
Step 1 - send a request for commands to be executed:
I: Sender Application > http://localhost:8080/input-commands?device=1&command=Y
O: <command><req-status>OK</req-status><id>1234-123</id></command>
Step 2 - Query results:
I: Sender Application > http://localhost:8080/result?id=1234-123
O: <command><id>1234-123</id><result>0</result></command>