How to obtain an OAuth token?


#1

I’ve seen the other thread about this, but I still can’t figure out how to whitelist my callback URL so I can kick off an oath flow.

The documentation mentions making a POST to /applications/{applicationId}/redirects and I have an App Key’ and an ‘App Secret’ but I don’t know how to authenticate this POST request, nor am I sure that the ‘App Key’ and the ‘applicationId’ are the same thing.

Am I supposed to trigger this POST from a logged in browser session? Is there some other way to authenticate this POST? The documentation doesn’t seem to cover non-oauth authentication.


#2

Hello @marc and welcome to the Cayenne Community. I’m tagging @hcortes here who should be better able to assist with these questions.


#3

Hi @marc,

For non-oauth authentication, make the a POST to https://auth.mydevices.com/oauth/token with the following payload:

{
   "grant_type": "password",
   "email": "YOUR EMAIL",
   "password": "YOUR PASSWORD"
}

This will return an access_token and a refresh_token. You are able to use the provided non-oauth access_token to manage your application which will be using an Authorization: Bearer ACCESS_TOKEN header.

And the application id and application key will the same throughout the docs.


#4

Thanks, this helped a lot.

I’m now able to do an explicit oauth flow and obtain a token from a user. I can create ‘things’ and list them in the API, using the token. I’ve even been able to ‘activate’ them by connecting to them using MQTT, but how do you get them to display in the cayenne dashboard? If I create a device using the bearer token obtained via the password authentication, it shows up in the cayenne dashboard fine. The devices created with the oauth token seem to be namespaced somewhere else, is there not a dashboard for those devices?

Basically I’d like to be able to create devices on a user’s cayenne dashboard auttomatically, is this not what the oauth grant is for?


#5

what post is it.Http/json


#6

Hi,
See https://youtu.be/KAMa5cLJgrU
I have used postman to obtain oAuth token