gcmcnutt / Sensor2

CMSensorRecorder direct to DynamoDB experiments
Apache License 2.0
4 stars 1 forks source link

amazon-only login seems to quit after an hour #17

Open gcmcnutt opened 7 years ago

gcmcnutt commented 7 years ago

e.g. a credentials refresh doesn't work -- gives error 8 or 9.

this may be a side effect of the watch going to sleep, or the app going to sleep -- needs some additional testing as the simulator proved to do continual refresh -- meaning the basic flow is correct

gcmcnutt commented 7 years ago

actually, the issue is that the refresh token is good for 50 minutes. this means, that essentially the phone needs to do the refresh on behalf of the watch no matter what.

or, maybe there is a way to have the login last a little longer.

(it looks like google token is good for 60 minutes).

gcmcnutt commented 7 years ago

For amazon token: here's the phone log when refresh is attempted after the 'expire'. the expire time noted on the phone is 2017-01-05T07:00:14Z -- the error is error 8.

Jan  5 21:14:25 liu101 sensor2[14319]: session message ["action": getCredentials]
Jan  5 21:14:25 liu101 sensor2[14319]: amazon: trigger refresh...
Jan  5 21:14:40 liu101 sensor2[14319]: amazon: refresh found token=Atza|IwEBII865Z9fWMJoZyKU7XUEGnuGS0CPT5cxPreJ0dBU8s9ZNhpt_ykaQeDXEfSjFRmNY-bJ7wTOFf_gsPkw1RQ2eH-vSoZMQujWyWJ5hRa-YC3gHnFlZhg2HYrv9MkMcYzjbr_4uKBTkyLFZEO6o0KiC4sEP8VOYpxvTVPfRpqpJXryUh89Q0hbhRCPm6SR-qEsoUtk1gn0_SGLeT98xj98bp7luv3931BVIzbj7TmGBfBxGKPUfe9sVTiEZ7vS67ZyK8qSuNYAn93XlCXPQhZ0NJhaBo0zWVxRS2B2Y7IILpj3sgjxzcg2XYk3kj4eL-2dWr_85Gtt0zjN-Lx-7S6ywhLco51YvJHxbE-FBqwk-VHG2dY47TIZZGybrEp3h2Tmx8B95JeQScmfkJrwbc2dWenLTKdoq4YtIPApUOwya84O4RL9lOX4aNKUtueMt81kRMmPZt4n1qNwCinYdztqIpnMHV_MGCj0LPUncTGfbh_qfXuvxjSrim32IX-r_XlTSGAdpVmS8mnrBItsmhiuZVek, expires=2017-01-05 07:00:14 +0000
Jan  5 21:14:40 liu101 sensor2[14319]: google: trigger refresh...
Jan  5 21:14:40 liu101 sensor2[14319]: The operation couldn’t be completed. (com.google.GIDSignIn error -4.)
Jan  5 21:14:40 liu101 sensor2[14319]: google: refresh found no token
Jan  5 21:14:40 liu101 sensor2[14319]: twitter: no authToken found
Jan  5 21:14:40 liu101 sensor2[14319]: facebook: refresh found no token
Jan  5 21:14:40 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Debug] AWSURLSessionManager.m line:537 | -[AWSURLSessionManager printHTTPHeadersAndBodyForRequest:] | Request headers:
    {
        "Content-Type" = "application/x-amz-json-1.1";
        Host = "cognito-identity.us-east-1.amazonaws.com";
        "User-Agent" = "aws-sdk-iOS/2.4.16 iOS/10.2 en_US";
        "X-Amz-Date" = 20170106T051440Z;
        "X-Amz-Target" = "AWSCognitoIdentityService.GetCredentialsForIdentity";
    }
Jan  5 21:14:40 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Debug] AWSURLSessionManager.m line:555 | -[AWSURLSessionManager printHTTPHeadersAndBodyForRequest:] | Request body:
    {"Logins":{"www.amazon.com":"Atza|IwEBII865Z9fWMJoZyKU7XUEGnuGS0CPT5cxPreJ0dBU8s9ZNhpt_ykaQeDXEfSjFRmNY-bJ7wTOFf_gsPkw1RQ2eH-vSoZMQujWyWJ5hRa-YC3gHnFlZhg2HYrv9MkMcYzjbr_4uKBTkyLFZEO6o0KiC4sEP8VOYpxvTVPfRpqpJXryUh89Q0hbhRCPm6SR-qEsoUtk1gn0_SGLeT98xj98bp7luv3931BVIzbj7TmGBfBxGKPUfe9sVTiEZ7vS67ZyK8qSuNYAn93XlCXPQhZ0NJhaBo0zWVxRS2B2Y7IILpj3sgjxzcg2XYk3kj4eL-2dWr_85Gtt0zjN-Lx-7S6ywhLco51YvJHxbE-FBqwk-VHG2dY47TIZZGybrEp3h2Tmx8B95JeQScmfkJrwbc2dWenLTKdoq4YtIPApUOwya84O4RL9lOX4aNKUtueMt81kRMmPZt4n1qNwCinYdztqIpnMHV_MGCj0LPUncTGfbh_qfXuvxjSrim32IX-r_XlTSGAdpVmS8mnrBItsmhiuZVek"},"IdentityId":"us-east-1:5850726e-940e-464d-9de3-9fc457985492"}
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Debug] AWSURLSessionManager.m line:566 | -[AWSURLSessionManager printHTTPHeadersForResponse:] | Response headers:
    {
        Connection = "keep-alive";
        "Content-Length" = 68;
        "Content-Type" = "application/x-amz-json-1.1";
        Date = "Fri, 06 Jan 2017 05:14:40 GMT";
        "x-amzn-ErrorMessage" = "Invalid login token.";
        "x-amzn-ErrorType" = "NotAuthorizedException:";
        "x-amzn-RequestId" = "06e5c0bd-d3cf-11e6-9970-0190252ffcf6";
    }
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Debug] AWSURLResponseSerialization.m line:63 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body:
    {"__type":"NotAuthorizedException","message":"Invalid login token."}
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Error] AWSCredentialsProvider.m line:431 | __87-[AWSCognitoCredentialsProvider getCredentialsWithCognito:authenticated:customRoleArn:]_block_invoke | GetCredentialsForIdentity failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=Invalid login token.}]
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Debug] AWSCredentialsProvider.m line:446 | __87-[AWSCognitoCredentialsProvider getCredentialsWithCognito:authenticated:customRoleArn:]_block_invoke | Resetting identity Id and calling getIdentityId
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Debug] AWSURLSessionManager.m line:537 | -[AWSURLSessionManager printHTTPHeadersAndBodyForRequest:] | Request headers:
    {
        "Content-Type" = "application/x-amz-json-1.1";
        Host = "cognito-identity.us-east-1.amazonaws.com";
        "User-Agent" = "aws-sdk-iOS/2.4.16 iOS/10.2 en_US";
        "X-Amz-Date" = 20170106T051441Z;
        "X-Amz-Target" = "AWSCognitoIdentityService.GetId";
    }
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Debug] AWSURLSessionManager.m line:555 | -[AWSURLSessionManager printHTTPHeadersAndBodyForRequest:] | Request body:
    {"IdentityPoolId":"us-east-1:53e91d7b-4528-4823-9bd0-fcfa545106bd","Logins":{"www.amazon.com":"Atza|IwEBII865Z9fWMJoZyKU7XUEGnuGS0CPT5cxPreJ0dBU8s9ZNhpt_ykaQeDXEfSjFRmNY-bJ7wTOFf_gsPkw1RQ2eH-vSoZMQujWyWJ5hRa-YC3gHnFlZhg2HYrv9MkMcYzjbr_4uKBTkyLFZEO6o0KiC4sEP8VOYpxvTVPfRpqpJXryUh89Q0hbhRCPm6SR-qEsoUtk1gn0_SGLeT98xj98bp7luv3931BVIzbj7TmGBfBxGKPUfe9sVTiEZ7vS67ZyK8qSuNYAn93XlCXPQhZ0NJhaBo0zWVxRS2B2Y7IILpj3sgjxzcg2XYk3kj4eL-2dWr_85Gtt0zjN-Lx-7S6ywhLco51YvJHxbE-FBqwk-VHG2dY47TIZZGybrEp3h2Tmx8B95JeQScmfkJrwbc2dWenLTKdoq4YtIPApUOwya84O4RL9lOX4aNKUtueMt81kRMmPZt4n1qNwCinYdztqIpnMHV_MGCj0LPUncTGfbh_qfXuvxjSrim32IX-r_XlTSGAdpVmS8mnrBItsmhiuZVek"}}
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Debug] AWSURLSessionManager.m line:566 | -[AWSURLSessionManager printHTTPHeadersForResponse:] | Response headers:
    {
        Connection = "keep-alive";
        "Content-Length" = 68;
        "Content-Type" = "application/x-amz-json-1.1";
        Date = "Fri, 06 Jan 2017 05:14:41 GMT";
        "x-amzn-ErrorMessage" = "Invalid login token.";
        "x-amzn-ErrorType" = "NotAuthorizedException:";
        "x-amzn-RequestId" = "0737d7bd-d3cf-11e6-ab12-478d8860c3b8";
    }
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Debug] AWSURLResponseSerialization.m line:63 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body:
    {"__type":"NotAuthorizedException","message":"Invalid login token."}
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Error] AWSIdentityProvider.m line:311 | __52-[AWSCognitoCredentialsProviderHelper getIdentityId]_block_invoke.259 | GetId failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=Invalid login token.}]
Jan  5 21:14:41 liu101 sensor2[14319]: AWSiOSSDK v2.4.16 [Error] AWSCredentialsProvider.m line:577 | __44-[AWSCognitoCredentialsProvider credentials]_block_invoke.353 | Unable to refresh. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=Invalid login token.}]
Jan  5 21:14:41 liu101 sensor2[14319]: error fetching credentials: The operation couldn’t be completed. (com.amazonaws.AWSCognitoIdentityErrorDomain error 8.)
Jan  5 21:15:21 liu101 routined[2558]: CoreLocation: Error occurred while trying to retrieve motion state update: CMErrorDomain Code:104
Jan  5 21:15:25 liu101 sensor2[14319]: NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)

And here is the watch logs:

Jan  5 21:14:23 liu101 sensor2 WatchKit Extension[14327]: dequeueLoop(3)
Jan  5 21:14:24 liu101 sensor2 WatchKit Extension[14327]: start flush to sensor2
Jan  5 21:14:24 liu101 sensor2 WatchKit Extension[14327]: refreshing userCredentials... send=true, wait=true
Jan  5 21:14:41 liu101 sensor2 WatchKit Extension[14327]: userCredentials refreshed cognitoId=nil
Jan  5 21:14:41 liu101 sensor2 WatchKit Extension[14327]: stop dequeuer...
Jan  5 21:14:42 liu101 sensor2 WatchKit Extension[14327]: exit dequeue loop
Jan  5 21:14:54 liu101 Carousel[2328]: [backlight] IOSSHLBacklight tickleAssertionTimeout:31000 does not exist
Jan  5 21:14:59 liu101 sensor2 WatchKit App[14325]: Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
Jan  5 21:15:36 liu101 syslogd[2323]: ASL Sender Statistics
gcmcnutt commented 7 years ago

So, the access token appears to be the only thing returned from the LoginWithAmazon framework -- the docs do seem to indicate the refresh token is in there, so we may need to wire in the new provider. e.g. this issue could be related to issue #2

I will first get #2 resolved and then come back to this one.