Claiming Photon using Two Legged Auth (iOS)

I currently have two-legged authentication setup, but I have a strange issue. I have successfully created a customer account from our main account. I am then able to go through the process to add a device using the customer access token, however when I get to the end of the setup process I am prompted with a message that says that it failed and I should try again (see image below). At this point, the photon is still blinking blue. Strangely if at that point I just reset the photon, it actually becomes successfully claimed by that customer account. Is there any reason I am getting this kind of behaviour? Why would I be getting this error screen if it in fact successfully registered the device to the customer account, and why did I have to hit reset on the proton to have it take effect?

Can you provide a list of steps (and SDK functions you called) to achieve what you described?

Thanks for the reply Ido, but I actually managed to contact some Particle reps about some of the specific problems we’ve been having and it’s been helpful. Apparently they were mostly known problems involving how the unclaiming process works - namely that unclaiming the device via the console/cloud doesn’t actually switch off the claiming flag in the device itself, it requires an extra step. Anyway, it’s mostly resolved now but thanks again.

Can you share you finds regarding changing the device’s claim flag. I’m in a similar situation…thanks!

Really comes down to both restoring the photon to factory settings on top of unclaiming it from the cloud. If you want to reset it physically, press and hold the setup button for 10 seconds to wipe the chip clean. Programatically, look here:

@steve-else, there is no “factory reset” on the Photon. Pressing and holding the setup button for 10 seconds only wipes the WiFi credentials and puts the device in Listening mode. The firmware on the device will still be there. If you want a “factory reset” you can put the device in Safe Mode and flash over (OTA or USB) the tinker app with desired system firmware version.

1 Like

You’re right about that, I shouldn’t have said factory reset, I meant wifi reset. For this particular problem a wiping of the wifi history by itself is enough to cure it. A complete reset including firmware might also be a good idea if you were unclaiming a device with the expectation that someone else will take it over from you, but it isn’t necessary.

I have also found that this problem and solution can’t be reproduced all the time. Sometimes you need to wipe just the wifi, sometimes you need to reset the keys, sometimes you don’t need to do anything at all. 90% of the time just a reset of the wifi credentials is enough. If you want to try various solutions until you find one that works for you, I’d suggest looking at the github link I posted earlier. I would suspect that the wiping of the wifi credentials alone should work for most people though (click and hold setup for 10 seconds)

I recently started running into this same issue. I was attempting to setup the device straight out of the box after ordering it and entered the wifi information correctly and it got to the end of the setup process. and failed on the verify device ownership step.

During the process I saw my server successfully request the new access token from the particle cloud, the access_token was received by the iOS client and then I called injectSessionAccessToken with that value. After going through the setup process and selecting the wifi access point and entering the credentials I can see the following logs:

2017-07-03 11:46:51.231478-0400 myapp[6395:779138] DeviceID sent
2017-07-03 11:46:51.260548-0400 myapp[6395:779138] DeviceID response received: <A_DEVICE_ID>
2017-07-03 11:46:51.260781-0400 myapp[6395:779138] PublicKey sent
2017-07-03 11:46:51.329365-0400 myapp[6395:779138] PublicKey response received
2017-07-03 11:46:51.329468-0400 myapp[6395:779138] ScanAP sent
2017-07-03 11:46:53.773406-0400 myapp[6395:779138] ScanAP response received
2017-07-03 11:46:53.773599-0400 myapp[6395:779138] Claim code - trying to set
2017-07-03 11:46:53.794780-0400 myapp[6395:779138] Device claim code set successfully: <A_DEVICE_CLAIM_CODE>
2017-07-03 11:46:56.761986-0400 myapp[6395:779138] SocketStream read error [0x1c416c000]: 1 54

When It gets to the verify device ownership step I can see these errors a few times:

2017-07-03 11:47:45.380793-0400 myapp[6395:780395] TIC TCP Conn Failed [17:0x1c01702c0]: 12:8 Err(-65554)
2017-07-03 11:47:45.382503-0400 myapp[6395:781434] HTTP load failed (error code: -1003 [12:8]) for Task <135C02D4-ED7D-4734-857F-13B1924BC79C>.<2>
2017-07-03 11:47:45.383324-0400 myapp[6395:781227] Task <135C02D4-ED7D-4734-857F-13B1924BC79C>.<2> finished with error - code: -1003
2017-07-03 11:47:46.068452-0400 myapp[6395:781039] TIC TCP Conn Failed [18:0x1c41654c0]: 12:8 Err(-65554)
2017-07-03 11:47:46.070006-0400 myapp[6395:781434] HTTP load failed (error code: -1003 [12:8]) for Task <36DCC8E1-87FE-41C2-BFF7-FE057A79EC3B>.<0>
2017-07-03 11:47:46.070254-0400 myapp[6395:781434] NSURLConnection finished with error - code -1003

Let me know if there is any additional information I can provide to help resolve this issue.

EDIT: I know this is a fairly old thread so if you would like me to open a new post to track this problem let me know.