Need a Access token for API

Hi

I have two apps running in one Pantaris project, one is a app another is a api.
When app wants to connect and call api endpoints it is asking access token.
We tried providing process.env.ACCESS_TOKEN at server side and localStorage.get(‘calponia.user.accessToken’) at client side but both did not worked were giving undefined.

We even tried all solutions mentioned here link but were unable to detect ctl command in exec pod.

Can you provide us a solution to have access token.

Hello rizwannargundkar,

currently we have no dedicated concept for app-to-app communication in the same project.

We know it is crucial for connected workflows and we are working on it.

For now you could create a device and for the device create a token. This token can access both applications. In order to let your app create a device token you will have to create a dedicated app manifest: Documentation | PANTARIS

The permission to create a device token is a special one and has to be requested explicitly. Additionally it will not work in an app sandbox but only for approved productive apps.

Here is what it could look like:

{
  "version": "0.0.1",
  "permissions": {
    "backend": [
      {
        "id": "project.CURRENT.devices.refresh-accesstoken"
      }
    ],
    "frontend": [ ]
  }
}

I hope that clarifies your question :slight_smile:

Is it possible to call this api below
Pantaris API CIAM
here I need the CIAM login code of the user. from where can I get that code ciam?

You can call it, but it will redirect the current user to the login. If its called from a backend it will not work because you will get a redirect to the user login promt.

The CIAM login code is returned after the user logged in, thats the only way to get it. Its purpose is to be secret and not used by anyone else that the real user on login. You do not have to take care of it. If the user is accessing your application. We will check if he is logged in and has access to the app and redirect him to the login if needed.

If you need an accesstoken, you can use the method i described above.

Hi @hans.ferchland

That https://api.pantaris.io/v2/users/login/ciam gives token in the response of current user so thought to give a try.
But anyway I will try what you suggested and provide you feedback.

and one more api is available GET access token
which provide the access token but require id which again we don’t know from where we get it.

If you create a device accesstoken you will once get the plain token (you can use for whatever you need it) and also the id. Even with the id, you can only check if it exists, you will never again get the plain token, so make sure to save it the first time.

1 Like

Find more information about how and when to use which token here: Documentation | PANTARIS

1 Like

We want this app to work in sandbox… it is still not a productive app.

I tried all the mentioned points from the given link authorization nothing worked.

Need help on how to setup Pantaris CTL.
It was unable to detect Pantaris CTL command.

Hello @rizwannargundkar,

this may expose a security risk and is therefore not possible for now. We already have concepts to allow this also for sandbox apps, but this will take some more time.

As a workaround you could use a hardcoded equipment token from a test project (only for the sandbox, never do this in production).

This is an experimental feature designed to control and inspect your app from your local computer, it is not designed for app to app communication at all.

Hello @rizwannargundkar !

The links given by @thomas.schuerle are basically correct, however some kind of incomplete.
What is missing there is the hint, how to use that token for the generated (IoT) Device.

You find this hint in the Pantaris API Documentation - quite prominently in the first section Authorization. It explains how you have to give your Device’s Token as an HTTP Header when hitting your Pantaris-hosted API.

Authorization: Token <your token goes here>

To conclude: all information is available, indeed, but it’s scattered and spread across various documentation sources.

Can we use device token to communicate between the apps in one PANTARIS projects?

yes, i answered this in the beginning: