Have two Android apps controlling one Electron/device without sharing email/password

Hi everyone,

I’ve had great success with using my Electron to control various products around my house. My most recent foray was putting together a replacement for a broken key fob for a car: Key Fob replacement for 2002 Ford using Particle Electron.

What I’m currently using is the sample code
ParticleCloudSDK.getCloud().logIn("ido@particle.io", "myl33tp4ssw0rd");
in conjunction with the:

<string name="oauth_client_id">(client ID string goes here)</string>
<string name="oauth_client_secret">(client secret 40-char hex string goes here)</string>

in the strings.xml file of the Android app.

I would now like to share the app so that two phones can control the same device (like having multiple remotes for the same car) without having to create a new login. Additionally, I would like to stop having to provide my username and password in the app and just use the client-ID and client secret. However, when I remove the login details, I get a Particle Cloud Exception:

W/System.err: io.particle.android.sdk.cloud.ParticleCloudException
W/System.err:     at io.particle.android.sdk.cloud.ParticleCloud.getDevice(ParticleCloud.java:527)
W/System.err:     at io.particle.android.sdk.cloud.ParticleCloud.getDevice(ParticleCloud.java:318)

How can I distribute the app to family members so we can all lock/unlock our car without having my personal Particle login username & password in the app’s code?

Thanks!

You can create an access token for each device and just use that.

Nice idea with the access token @ScruffR!

What’s the best way to use an access token with the Android SDK?

I’m not sure how to use them.

@ScruffR Is it possible to generate separate token for each device separately?
Is not there just one token for all devices you have on your account?

Due to the OPs question “device” in this respose does refer to mobile device to use to control any Particle device for that account and not to the Particle device.

But, you can create hundreds and thousands of access tokens if you wish, either via the API endpoint or for testing via CLI

particle token new

:wink: have a look how many you already got via

particle token list
1 Like