Skip to content

Cloud SDK: "Generate an access token" section is missing some info #1132

Open
@BryanKadzban

Description

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 "joe@example.com" (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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions