1

I am referring to the documentation on the MobileFirst Server push service REST API for Push Device Registration (POST). From the document (https://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.apiref.doc/rest_runtime/r_restapi_push_device_registration_post.html), the payload looks like this

{
  "deviceId" : "12345-6789",
  "phoneNumber" : "123456789",
  "platform" : "A",
  "token" : "xyz",
}

I can see that the description for token is "Device token obtained via the service provider" but i still do not understand where i am supposed to obtain this token from.

Is there some other api i need to call to get this "token"? If so, what is the API? If not, then where am i supposed to get this from?

kwenyao
  • 67
  • 7

2 Answers2

2

The device token is provided by the push notification cloud providers like GCM,APNS. When app is installed on mobile device, then the push sdk communicates with the push notification cloud providers(Gcm, apns) and receives the token.

When the device is registered with mobilefirst server, then this token is sent to the mobilefirst server and stored in database.

So there is no other api which can be used to get this token

Rahul Roy
  • 81
  • 4
  • I am thinking of calling this push registration api via an adapter. Is there any documentation on how i can do this or how i can get the token? – kwenyao Feb 21 '18 at 12:06
  • The token is received at a device. If you wish to invoke registration API from an adapter, you need to obtain the token at the device ( natively), pass it on to the adapter. But there is no way you can invoke the push endpoint directly from the adapter. This is because, push endpoint is protected and needs to have the appropriate OAuth token. You will otherwise need to obtain the Push OAuth token separately at the client and pass it to server. If you are already doing it, might as well use the Push SDK for registration as well. – Vivin K Feb 21 '18 at 14:36
0

Acquiring access tokens

To obtain an access token, the confidential client sends an access-token request with the "client_credentials" grant type, as described in the OAuth specification. The token request is an HTTP POST request that is sent to the URL of the token endpoint. The URL pattern for accessing the token endpoint is as follows (replace the <...> placeholders with your custom data):

http(s)://<server_ip>:<server_port>/<project_name>/api/az/v1/token

In the request, include the HTTP authorization header. The authorization server uses this header to authenticate the confidential client.

For more detail see: https://www.ibm.com/support/knowledgecenter/en/SSHS8R_8.0.0/com.ibm.worklight.dev.doc/dev/c_non_mobile_to_mobile_services.html

Gaurab Kumar
  • 2,144
  • 2
  • 17
  • 29
  • The 'token' that you have mentioned in your answer is for the Authoriation: Bearer header for the mobilefirst REST API calls. This is not the token which i am referring to. The one i need is for the request body for push notification registration. – kwenyao Feb 22 '18 at 03:37