You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately I don't see where the sources for this part of the docs are stored; they're not in this repository, as searching it for "[email protected]" (in the example set of requests) or "oauth grant type" (in the description of the grant_type form field) finds nothing.
One issue is that the grant_type field is very under-documented. It's true that a pure username and password login to a developer account uses the "password" grant_type. But if your developer account has MFA turned on, you get an mfa_required error code with an mfa_token field, but nowhere in the docs does it say what to do with that. You have to set grant_type to urn:custom:mfa-otp, set otp to the six-digit code from the external authenticator, and set mfa_token to the token string that the error response sent. (Per https://community.particle.io/t/rest-cloud-api-multifactor-response/51062)
It would be much better if the grant_type field had full documentation on the different accepted types. password is given already; it requires the username and password fields. client_credentials is used for products (it would be good to link to the explanation in the device-cloud authentication tutorial, and outline which form fields are required). urn:custom:mfa-token requires mfa_token and otp (and I'm also re-sending the username and password in my client ... but I don't know if that's required).
A second issue is that the "refresh_token" field in a successful response is also under-documented. It says "used to generate a new access token when it has expired", but this is not entirely true; the refresh tokens also only work for a product, not for "normal" developer account logins. That's documented elsewhere (in the authentication tutorial), but should be here too since it's part of the API.
@BryanKadzban - Thank you for posting this. I was going crazy trying to figure out what was wrong given the mfa_token error, but nothing else in the Particle Documentation.
For anyone else, just to summarize -- you need 2 requests:
https://docs.particle.io/reference/device-cloud/api/#generate-an-access-token
Unfortunately I don't see where the sources for this part of the docs are stored; they're not in this repository, as searching it for "[email protected]" (in the example set of requests) or "oauth grant type" (in the description of the grant_type form field) finds nothing.
One issue is that the grant_type field is very under-documented. It's true that a pure username and password login to a developer account uses the "password" grant_type. But if your developer account has MFA turned on, you get an mfa_required error code with an mfa_token field, but nowhere in the docs does it say what to do with that. You have to set grant_type to urn:custom:mfa-otp, set otp to the six-digit code from the external authenticator, and set mfa_token to the token string that the error response sent. (Per https://community.particle.io/t/rest-cloud-api-multifactor-response/51062)
It would be much better if the grant_type field had full documentation on the different accepted types. password is given already; it requires the username and password fields. client_credentials is used for products (it would be good to link to the explanation in the device-cloud authentication tutorial, and outline which form fields are required). urn:custom:mfa-token requires mfa_token and otp (and I'm also re-sending the username and password in my client ... but I don't know if that's required).
A second issue is that the "refresh_token" field in a successful response is also under-documented. It says "used to generate a new access token when it has expired", but this is not entirely true; the refresh tokens also only work for a product, not for "normal" developer account logins. That's documented elsewhere (in the authentication tutorial), but should be here too since it's part of the API.
I would generate both of these changes and make a pull request, but I can't find them in the repository. I did find the note at the top of https://github.com/particle-iot/docs/blob/master/src/content/reference/device-cloud/api.md though, saying to open a GitHub issue instead of changing the doc. So here I am.
The text was updated successfully, but these errors were encountered: