I have been trying to get my REST API apps working again after the upgrade a few months ago, and the Happy Holidays release.
There was a question in another topic, but I have started a new topic with a better title, as we are talking to posterity.
What I have found is that the old system is still working, with the https://auth.mydevices.com/oauth/token call. Specifically my VBA Excel implementation is working (links at the bottom) for a token grant but not the token refresh call, and the Java Android implementation does not work for grant or refresh, but the rest of the calls for accessing things and data work when I hardcode a good access token. And sending curl calls with that link above also works fine for the grant, but not the refresh.
The particularly strange thing is that my old Java Android code for synchronous http request for a grant does work, but the same code (with a different http library) for asynchronous calls does NOT work. And you cannot send synchronous http requests in a Android App on the main thread, so I have a little kludge to start a new thread to get the access token. When I use my old code for asynchronous request, it always returns with http 500 Internal Server Error, but the identical calls with synchronous JAVA, with VBA, and with curl all work fine - same link, same username password, same x-www-form-urlencoded. I even rewrote it to send the username/password in a JSON, but I got the 500 Internal Server Error. My theory is that the server is redirecting the call somehow to the new link https://accounts.mydevices.com/auth/realms/cayenne/protocol/openid-connect/token which is causing problems with the asynchronous call, but the synchronous, curl, and VBA all more accommodating to the redirection, or whatever is happening.
So then I made an attempt to rewrite things according to the new system using /auth/realms/… system, but have had no success. That new system requires a client_id and sometimes a client_secret_id. There is a client_id with each device which is used in the mqtt world, but this client_id / secret_id from the OAuth2 world is different. There is not secret_id on the dashboard or in the mqtt world.
As I understand OAuth2, the client_id and secret is used in the system where I don’t have a cayenne account, and I am using my facebook or google account to log in to cayenne. So my “client” is not one of my mqtt devices, but rather the client is an application what connects the facebook/google with cayenne, so cayenne will let my application access the cayenne data based on my facebook/google credentials.
So the simple test from the new REST API doc …
curl -X POST --header ‘Content-Type: application/x-www-form-urlencoded’ --header ‘Accept: application/json’ -d ‘grant_type=password&email=foobar%40example.com&password=example&client_id=123456’ ‘https://accounts.mydevices.com/auth/realms/cayenne/protocol/openid-connect/token’
which asks client_id, but not client_secret, doesn’t work for me. My mqtt cleint numbers 8x-4x-4x-4x-10x do not work, nor the random number 123456. I think this client_id is a OAuth2 client that is used for this facebook-cayenne connection.
So I’m looking for insight on that matter - what is the client_id? and also on the other matter of why I can get a access grant using curl and old code on the old link, but it all fails with a http 500 when I use my old code with the asynchronous connection? And can I still use the old token refresh system without resolving this new client_id issue with the realms system.
Or correct me wherever I have gone wrong!