nokia-api-gateway
v0.0.5
Published
Gateway to Nokia API
Downloads
7
Maintainers
Readme
Nokia Health Gateway
The Gateway server to communicate with Nokia Health API
- Authorize Nokia Health API using OAuth 1
- Get body measures
Problem
If we implement OAuth application using only client side, it cannot keep consumer key and consumet secret secretly.
In order to create a secure application, you should not store consumer key and consumer secret on the client side.
So we create server application easy to use.
Install
npm install nokia-api-gateway
If you using Yarn,
yarn add nokia-api-gateway
Getting started
Prerequisite
This repository depends on AWS API Gateway with Lambda proxy integration.
Launch server locally
# See #settings
export NOKIA_GATEWAY_REGION=xxx
export NOKIA_GATEWAY_S3_BUCKET_NAME=xxx
export NOKIA_GATEWAY_CF_STACK_NAME=xxx
export NOKIA_GATEWAY_FUNCTION_NAME=xxx
export NOKIA_GATEWAY_AWS_ACCOUNT_ID=xxx
PORT=8888 $(npm bin)/nokia-api-gateway serve
Then open http://localhost:8888
.
Settings
|Name|Description|Required|Default|
|---|---|---|---|
|NOKIA_GATEWAY_REGION
|AWS Region|Yes|-|
|NOKIA_GATEWAY_S3_BUCKET_NAME
|S3 bucket to place application bundle|Yes|-|
|NOKIA_GATEWAY_CF_STACK_NAME
|Name of cloudformation stack|Yes|-|
|NOKIA_GATEWAY_FUNCTION_NAME
|Name of lambda function|Yes|-|
|NOKIA_GATEWAY_AWS_ACCOUNT_ID
|AWS account id|Yes|-|
|NOKIA_GATEWAY_CONSUMER_KEY
||Yes|-|
|NOKIA_GATEWAY_CONSUMER_SECRET
||Yes|-|
Deploy to AWS API Gateway
# Create S3 bucket (if not exists)
aws s3 mb s3://$NOKIA_GATEWAY_S3_BUCKET_NAME
# Deploy
$(npm bin)/nokia-api-gateway deploy
API specification
GET /oauth_request
Generate an oAuth token to be used for the End-User authorization call.
Parameters
None
Response
{
"success": true,
"requestTokenSecret": "xxxxxxxx",
"authUrl": "https://developer.health.nokia.com/account/authorize?oauth_consumer_key=XXXX&oauth_nonce=XXXX&oauth_signature=XXXX%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1498282240&oauth_token=XXXX&oauth_version=1.0"
}
{
"success": false,
"error": "some error message"
}
- requestTokenSecret: To use
POST /oauth_access_token
- authUrl: URL of Nokia authorization screen
POST /oauth_access_token
Request an OAuth token that will let you access a specific user's data.
Headers
- Content-Type:
appliation/json
Parameters
- oauthToken: OAuth token (please refer this document)
- requestTokenSecret: See
GET /oauth_request
Response
{
"accessToken": "d4e8874f6e6d4204fc98b5723221559376dc58019802c10cf16b7e9f443",
"accessTokenSecret": "20d42817e16b6ddd3e117d0b7b02534cd13595558870ce0b5cebccf14",
"results": {
"deviceid": "0"
}
}
{
"success": false,
"error": "some error message"
}
- accessToken: Access token
- accessTokenSecret: Access token secret
GET /body_measures
Get the body measures for a user
Headers
- Content-Type:
appliation/json
Parameters
- accessToken: Access token
- accessTokenSecret: Access token secret
- userId: Nokia user id
Response
{
"measuredData": { ... }
}
{
"success": false,
"error": "some error message"
}
For more details, please refer: https://developer.health.nokia.com/api/doc#api-Measure-get_measure