Hi @jeiden, I’m sorry but I spoke too soon.
TL;DR - getDevices
works after registration, but not after the user signs out and then signs back in again.
When I register a new user using the Android or iOS setup SDKs, the new user is authenticated using the following method:
Responses.LogInResponse signUpAndLogInWithCustomer(@Field("grant_type") String grantType,
@Field("email") String email,
@Field("password") String password,
@Path("orgSlug") String orgSlug);
This creates the following request / response:
---> HTTP POST https://api.particle.io/v1/orgs/<<< ORG SLUG >>>/customers
03-04 02:09:07.065 2336 2363 D Retrofit: Authorization: Basic <<< ORG TOKEN >>>==
03-04 02:09:07.065 2336 2363 D Retrofit: Content-Type: application/x-www-form-urlencoded; charset=UTF-8
03-04 02:09:07.066 2336 2363 D Retrofit: Content-Length: 89
03-04 02:09:07.066 2336 2363 D Retrofit: grant_type=client_credentials&email=<<< EMAIL >>>&password=<<< PASSWORD >>>
03-04 02:09:07.066 2336 2363 D Retrofit: ---> END HTTP (89-byte body)
03-04 02:09:07.765 2336 2363 D Retrofit: <--- HTTP 201 https://api.particle.io/v1/orgs/<<< ORG SLUG >>>/customers (699ms)
03-04 02:09:07.765 2336 2363 D Retrofit: Server: nginx
03-04 02:09:07.765 2336 2363 D Retrofit: Date: Fri, 04 Mar 2016 07:09:07 GMT
03-04 02:09:07.765 2336 2363 D Retrofit: Content-Type: application/json; charset=utf-8
03-04 02:09:07.765 2336 2363 D Retrofit: Content-Length: 178
03-04 02:09:07.765 2336 2363 D Retrofit: Connection: keep-alive
03-04 02:09:07.765 2336 2363 D Retrofit: Access-Control-Allow-Origin: *
03-04 02:09:07.765 2336 2363 D Retrofit: OkHttp-Selected-Protocol: http/1.1
03-04 02:09:07.765 2336 2363 D Retrofit: OkHttp-Sent-Millis: 1457075347371
03-04 02:09:07.765 2336 2363 D Retrofit: OkHttp-Received-Millis: 1457075347765
03-04 02:09:07.766 2336 2363 D Retrofit: {
03-04 02:09:07.766 2336 2363 D Retrofit: "token_type": "bearer",
03-04 02:09:07.766 2336 2363 D Retrofit: "access_token": "<<< ACCESS TOKEN >>>",
03-04 02:09:07.766 2336 2363 D Retrofit: "expires_in": 7776000,
03-04 02:09:07.766 2336 2363 D Retrofit: "refresh_token": "<<< REFRESH TOKEN >>>"
03-04 02:09:07.766 2336 2363 D Retrofit: }
03-04 02:09:07.766 2336 2363 D Retrofit: <--- END HTTP (178-byte body)
I am able to list the user’s devices with this token using the getDevices
method from the SDK.
But then when I sign out and sign back in again, I am no longer able to list the user’s devices. The login request looks like this:
> 03-04 02:10:45.047 2336 2365 D Retrofit: ---> HTTP POST https://api.particle.io/oauth/token
> 03-04 02:10:45.047 2336 2365 D Retrofit: Authorization: Basic <<< ORG TOKEN >>>==
> 03-04 02:10:45.047 2336 2365 D Retrofit: Content-Type: application/x-www-form-urlencoded; charset=UTF-8
> 03-04 02:10:45.047 2336 2365 D Retrofit: Content-Length: 82
> 03-04 02:10:45.047 2336 2365 D Retrofit: grant_type=password&username=<<< EMAIL >>>&password=<<< PASSWORD >>>
> 03-04 02:10:45.047 2336 2365 D Retrofit: ---> END HTTP (82-byte body)
> 03-04 02:10:45.488 2336 2365 D Retrofit: <--- HTTP 200 https://api.particle.io/oauth/token (441ms)
> 03-04 02:10:45.488 2336 2365 D Retrofit: Server: nginx
> 03-04 02:10:45.488 2336 2365 D Retrofit: Date: Fri, 04 Mar 2016 07:10:45 GMT
> 03-04 02:10:45.488 2336 2365 D Retrofit: Content-Type: application/json; charset=utf-8
> 03-04 02:10:45.488 2336 2365 D Retrofit: Content-Length: 178
> 03-04 02:10:45.488 2336 2365 D Retrofit: Connection: keep-alive
> 03-04 02:10:45.488 2336 2365 D Retrofit: Access-Control-Allow-Origin: *
> 03-04 02:10:45.488 2336 2365 D Retrofit: Cache-Control: no-store
> 03-04 02:10:45.488 2336 2365 D Retrofit: Pragma: no-cache
> 03-04 02:10:45.488 2336 2365 D Retrofit: X-Content-Type-Options: nosniff
> 03-04 02:10:45.488 2336 2365 D Retrofit: OkHttp-Selected-Protocol: http/1.1
> 03-04 02:10:45.488 2336 2365 D Retrofit: OkHttp-Sent-Millis: 1457075445299
> 03-04 02:10:45.488 2336 2365 D Retrofit: OkHttp-Received-Millis: 1457075445487
> 03-04 02:10:45.489 2336 2365 D Retrofit: {
> 03-04 02:10:45.489 2336 2365 D Retrofit: "token_type": "bearer",
> 03-04 02:10:45.489 2336 2365 D Retrofit: "access_token": "<<< ACCESS TOKEN >>>",
> 03-04 02:10:45.489 2336 2365 D Retrofit: "expires_in": 7776000,
> 03-04 02:10:45.489 2336 2365 D Retrofit: "refresh_token": "<<< REFRESH TOKEN >>>"
> 03-04 02:10:45.489 2336 2365 D Retrofit: }
> 03-04 02:10:45.489 2336 2365 D Retrofit: <--- END HTTP (178-byte body)
There doesn’t seem to be any way to specify the grant_type
for the login request from the setup SDK.
So why does the getDevices
method work after registration, but not after login? Is this by design?