Hello,
I am trying to use ParticleCloudSDK
on Android to access a user’s device list. I am using two legged authentication. I’ll try to make it clear what I am doing from the start.
- I have created a product and corresponding client id and client secret for my Android app
- a new user opens my app and creates an account with my back end
- I create a shadow customer in the particle cloud and get an access token
- I store the user’s access token in my database
Then (this could be right away or after the app is restarted):
- The user signs in with my authentication
- I call
ParticleCloudSDK.initWithOauthCredentialsProvider(ctx, CredentialsProvider)
whereCredentialsProvider
provides the client id and secret - I get their access token from my database
- I set the access token with the particle cloud:
ParticleCloudSDK.getCloud().accessToken = <token>
- Then I try to access the user’s devices (according to the console the user owns one device) with
ParticleCloudSDK.getCloud().devices
but the size is 0. AlsoParticleCloudSDK.getCloud().isLoggedIn
isfalse
.
I thought I read somewhere else that setting the access token with ParticleCloudSDK.getCloud().accessToken = <token>
should result in ParticleCloudSDK.getCloud().isLoggedIn
being true
.
Is that not the case?
Should I be going about this in a different way?
Any help is appreciated.
Thanks!
Edit: Looks like I was trying to call ParticleCloudSDK.getCloud().devices
on the UI thread and that was the reason it was failing.