Two-Legged Authentication with iOS App

Hi Particle Community,

My goal is to build an iOS app with two-legged authentication. I am unsure about the workflow, and I was hoping you could please help me.

Here’s my understanding of the workflow:

  1. First, create a customer using the https://api.particle.io/v1/orgs/my_organization/customers endpoint. This call requires parameters: client_id, client_secret, “shadow” user email, and no_password: true.

  2. Upon success, this call returns an access_token, refresh_token and expiration time. With this access_token, you then make a request to the https://api.particle.io/v1/orgs/my_organization/products/my_product/device_claims endpoint to get the claim code.

  3. This is where I’m stuck. So far, in my servers I have the “shadow” user, access_token and claim code.

In the iOS app, I installed the Setup SDK. The Spark Setup Screen requires both an email and password from the app’s customer. What password should the customer enter? The customer was created in the Cloud API without a password.

My attempt: I tried launching the SparkSetupMainController with the “setupOnly” option, but then the wizard is unable to claim the device. Where do I pass the claim code I got from your API, to the SparkSetupMainController?

Thank you for your help, it would be greatly appreciated!