Oracle Mobile Cloud Service is a mobile backend as a service. MCS does its magic by providing a lot of features to make implementing mobile services easy such as (among many other) authentication, logging/analytics, lookups and calling other services. There are also features available to make integration with mobile clients easy such as providing an easy way to implement push notifications.
The described example is not suitable for a production implementation and is based on limited experience (and watching some really nice YouTube presentations ). It is provided to give an idea on how to get started easily with a simple working example.
From the ProgrammableWeb site I found OpenWeatherMap . This site provides current weather and forecasts via an easy to use API. You can get a free account which allows up to 600 calls per 10 minutes. This is enough for this demonstration.
Once you have generated an API key, you can call the API with a GET request onhttp://api.openweathermap.org/data/2.5/weather?q=[location,country]&APPID=[your API key]
Location,country can be for example Birmingham,GB or Groningen,NL
After you have generated an API key, you can use your favorite REST service testing tool to check if you can call the service. The below screenshot is from Postman, a Chrome plugin.
In order to get started with MCS, you first need to create a Mobile Backend. A Mobile Backend has a Mobile Backend Id. This will be used later to call API's available on this backend.
Next you create the connector to the OpenWeatherMap API.
You should of course test your connector
Next you should define your API. In the below screenshot you can already see some of the platform services which are available.
When defining the API, it is easiest if you use a prepared RAML file.
For security, I created a user (MaartenSmeets) under Mobile User Management, granted the user a role (MY_ROLE) and set the below properties to allow that user to call my API.
The API needs to be assigned to a Mobile Backend.
Implementing a custom API
The connector needs to be a dependency in the package.json file.
After you ZIP this and upload it to MCS as an API implementation, you can test your API.
I have used basic authentication here as defined when defining the API. I use the credentials of a user who is granted the specified role. With the request you also need to specify the Mobile Backend Id as an Oracle-Mobile-Backend-Id HTTP header.
After you have done this, you have an end to end sample working! You can browse the log files from Administration, Logs to confirm your message has arrived and browse console.log messages. This is also useful for debugging.
FinallyAs usual, Oracle has done a good job at providing thorough documentation. Next to the YouTube presentations, the following