Simple oAuth Creating new customer to existing product failed

I am creating a test ios app to try out/understand the onboarding process using Simple oAuthentication. In the project I have added ParicleDeviceSetupLibrary so that I can use the initial setup UI wizard. I have signed up in Particle Dashboard to create a user credential ‘A’. Under credential A, I created a new product using simple oAuth and added a device (using PariclePhoton#1).
Using the my TestApp I mentioned eariler, I was able to login through the wizard, connect to WIFI and talk to the PariclePhoton #1.

Following step 3, in the document
I am trying to add a new customer to the existing product via this setup Wizard in my App but this fails. With a fresh user/pwd I select the ‘add new user’ function and provide the user/pwd credentials. But this fails

xcode debug error code for New User sign up

2017-01-20 13:06:11.968686 ParticleConnect[916:266511] ! SparkCloud could not subscribe to devices system events No active access token
2017-01-20 13:07:18.700628 ParticleConnect[916:266511] [MC] System group container for path is /private/var/containers/Shared/SystemGroup/
2017-01-20 13:07:18.713130 ParticleConnect[916:266511] [MC] Reading from public effective user settings.
2017-01-20 13:07:37.885912 ParticleConnect[916:266511] Can't find keyplane that supports type 7 for keyboard iPhone-PortraitTruffle-Emoji; using 2689976931_PortraitTruffle_iPhone-Emoji-Keyboard_Letters
2017-01-20 13:07:56.976277 ParticleConnect[916:266511] ! loginWithUser Failed (status code 400): {
    error = "invalid_grant";
    "error_description" = "User credentials are invalid";

I have tried adding new user using the Tinker App and it showed the exact same error and behavior.

Been at this for several days now, at my wits end, any help will be very much appreciated.


Hi Kenneth, do you mean to leave a message ?

I dont do iOS, I just do web development… but maybe I can help.

Are you trying to “create a user” via an API call? It looks like error message you are getting indicates you are not supplying the server with the information it is looking for.

I am guessing you are missing the credentials(client ID and secret)

Thank you for the reply.
The (pretending) new user that wants to sign up for a particle account should not have any client ID and secret yet. That’s why one is trying to create it.
My app just us a simple API call SparkSetupMainController( ) (one line of code) to bring up the sign up page wizard as suggested by Particle’s document. The wizard is shown in image above.

Did you ever got this resolved? I get the exact same error response.

For simplicity, I set my id and secret in plain text (no cocoapods-keys):

SparkCloud.sharedInstance().oAuthClientId = "myId"
SparkCloud.sharedInstance().oAuthClientSecret = "mySecret"

And then call:

@IBAction func setupDeviceBtn(_ sender: Any) {
	if let setupController = SparkSetupMainController()   {
		// check organization setup mode
		let customization = SparkSetupCustomization.sharedInstance()
		customization?.allowSkipAuthentication = true
		setupController.delegate = self
		setupController.modalPresentationStyle = .formSheet  // use that for iPad
		self.present(setupController, animated: true, completion: nil)

Which results in that error 400 response and the debug stack:

2017-05-03 22:24:59.067 particleAUTHtest[3353:4556643] ! SparkCloud could not subscribe to devices system events No active access token
2017-05-03 22:25:04.966 particleAUTHtest[3353:4556643] -canOpenURL: failed for URL: "org-appextension-feature-password-management://" - error: "This app is not allowed to query for scheme org-appextension-feature-password-management"
2017-05-03 22:25:06.866570-0700 particleAUTHtest[3353:4556643] [MC] System group container for path is /Users/joost/Library/Developer/CoreSimulator/Devices/53307D8C-D698-4847-A66E-F281EC3A0864/data/Containers/Shared/SystemGroup/
2017-05-03 22:25:06.869235-0700 particleAUTHtest[3353:4556643] [MC] Reading from private effective user settings.
2017-05-03 22:25:56.454176-0700 particleAUTHtest[3353:4558894] PAC Fetch failed with error [NSURLErrorDomain:-1003]
2017-05-03 22:25:56.454498-0700 particleAUTHtest[3353:4558894] [] nw_proxy_resolver_create_parsed_array PAC evaluation error: NSURLErrorDomain: -1003
2017-05-03 22:25:57.185 particleAUTHtest[3353:4556643] ! loginWithUser Failed (status code 400): {
    error = "invalid_grant";
    "error_description" = "User credentials are invalid";

I’ve gone over this a few times and can’t see what I am doing wrong. I know the credentials are proper.


(swift 3.1, xcode 8.3 in case that matters)

Failed to mention that when I run through the setup above (to get the user account created) two or more times, the second time the error is “Could not sign up; user already created”. This leaves me to believe that the first step may have been correct somehow and the first error message complaining about improper credentials is bogus.

I’d really like some help from the particle boys & girls here!