Step 1: Register your app
To start things off, the rain gods need to know about your application. This can be done by visiting make.lono.io
, and clicking Login in the upper right. Login with your Lono account, and click the dev settings button in the navbar.
Click Add a new Application
, and fill out the required fields. Enter the approximate amount of users that you expect to use the application (If you are thinking of selecting Just Me
then take a look at creating a single user application). Note that the callback URL cannot be changed, and without this users won't be able to authorize and use the app.
After clicking Create my app, mon!
, Lono knows about your application!
Step 2: Record your keys and make a request
Make sure to keep track of your Client Id
and Client Secret
- you'll need these later! Next, click Test OAuth Request
- this will prompt you for authorization for your third party application to be given write access to your Lono. If you are thinking of deploying your app publicly, then this is the place you'll want to send new users. After allowing the request, you will be redirected. Here's a quick map of the structure, so you can craft a valid request:
/dialog/authorize
?response_type=code
&client_id=[Client ID of Application]
&redirect_uri=[Where to Redirect on a successful query]
&scope=[Permissions, comma seperated. [more about this here](request-permissions)]
Step 3: Find your keys!
Once a user has authorized, listen on that callback URL: a request will come containing the authorization code in the body. That request will contain:
code: [auth token]
It will be a GET
request to the specified callback url.
Step 4: Get your session token
Run the command below, replacing values where specified.
curl -X POST -H "Content-Type: application/json" -d '
{
"grant_type": "authorization_code",
"client_id": "[CLIENT ID HERE]",
"client_secret": "[CLIENT SECRET HERE]",
"code": "[ACCESS TOKEN HERE]"
}' http://make.lono.io/oauth/token
This query returns, if formatted correctly:
{
"access_token": "[ACCESS TOKEN]",
"token_type": "bearer"
}
Step 5: Do some stuff!
Now, with an access token, you can command the rain gods! Take a look to the right for all the API calls you can make!