Android Particle Cloud SDK not logged in after setting access token

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.

  1. I have created a product and corresponding client id and client secret for my Android app
  2. a new user opens my app and creates an account with my back end
  3. I create a shadow customer in the particle cloud and get an access token
  4. I store the user’s access token in my database

Then (this could be right away or after the app is restarted):

  1. The user signs in with my authentication
  2. I call ParticleCloudSDK.initWithOauthCredentialsProvider(ctx, CredentialsProvider) where CredentialsProvider provides the client id and secret
  3. I get their access token from my database
  4. I set the access token with the particle cloud: ParticleCloudSDK.getCloud().accessToken = <token>
  5. 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. Also ParticleCloudSDK.getCloud().isLoggedIn is false.

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.