How to build third-party apps using Pantahub API

With Pantahub, you can build your own applications around the Pantahub device ecosystem. This opens up a whole world of possibilities of what could be done and deployed directly to our device´s ecosystem.

Some examples of these capabilities are:

  • one.apps.pantahub.com: One is a web application that allows you to install and manage a wifi hotspot in any Raspberry PI with Pantahub. This will add a new platform to your device and deploy new revisions of the device when you change any configuration.
  • highercomve.github.io/dolly: Dolly is a web application that allows you to copy devices, platforms, or configurations from one device to another, allowing the user to compose or update devices using another device as a source, that device could be owned by you or any public device.

In order to build an application using the Pantahub platform you will need to complete these steps:

  1. Log in with (or Create) your Pantahub account
  2. Create the application inside your Pantahub account
  3. Get to know our platform and API
  4. Authenticate the user using Pantahub OAuth service
  5. Use the user token to communicate with the API

Log in with (or Create) your Pantahub account

This could be as simple as going to www.pantahub.com and creating or logging into your Pantahub account. You can even use your preferred OAuth provider like Google, Github, or Gitlab.

Create the application inside your Pantahub account

In order to use our OAuth Provider and gain access to proper permissions for your application’s user, you need to set up your application on Pantahub.

When you are creating a new application, you need to fill in these fields:

  • Name: this one is self-explanatory
  • Type: the application type could be Public or Confidential, and this refers to the grant types inside the OAuth specification. We accept those which have an “Authorization Code” (confidential type) or “Implicit” (public type)
  • Reading scopes: A list of scopes you want to use from the user. Those start from reading user’s information as the minimal amount of data you can get, and from there you have read/write devices, read/write trails , and complete access.
  • Callback URL whitelist: List of permitted callbacks URLs used by the OAuth provider.

Getting to know our platform and API

In order to have a good sense of how Pantahub and Pantavisor work, we have this detailed Blog Post and you could go and read about the API in our documentation, or you could just read the swagger documentation

Authenticate the user using Pantahub OAuth service

Pantahub is an OAuth provider like any other, therefore you will just need to use the authorization window to create a new token for your application.

This is an example of how you ask for permissions using OAuth

https://www.pantahub.com/oauth2/authorize?client_id=APP_PRN&scope=prn:pantahub.com:apis:/base/user.readonly&redirect_uri=APP_CALLBACK_URL&response_type=RESPONSE_TYPE
  • APP_PRN: is the one you have on the application detail pantahub.com/u/user/thridpartyapps
  • CALLBACK_URL: One of the available callback URLs for your application
  • RESPONSE_TYPE: Type of response you expect to receive from the OAuth provider, options are [token, code]. Using token as type will return the token as an implicit URL, which means {CALLBACK_URL}#token=TOKEN_STRING in other cases will return a code that needs to be exchanged by using it in the login endpoint and using the CLIENT_ID and CLIENT_SECRET

Use the user token to communicate with the API

Now that you have the user token, you could use it to communicate with the API on behalf of the user.

You could start to build your own application using Pantahub. You can read the source code of dolly, an open-source application in which you can move platforms from one device to another.

https://github.com/highercomve/dolly/

Happy trailing!
@highercomve