{"action":"created","comment":{"url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/comments/70705480","id":70705480,"diff_hunk":"@@ -128,7 +129,32 @@ AuthenticationResult acquireTokenWithRefreshToken(final String refreshToken)\n                 Logger.i(TAG, \"Refresh token is not returned or empty\", \"\");\n                 result.setRefreshToken(refreshToken);\n             }\n-        } catch (final IOException | AuthenticationException exc) {\n+        } catch (final AuthenticationException exc) {\n+            //if get 503,504,500 && outageMode is on, return the stale token\n+            if (exc.getCode().equals(ADALError.SERVER_NOT_RESPONDING) && mOutageModeIsOn) {\n+                final TokenCacheItem accessTokenItem = mTokenCacheAccessor.getRegularRefreshTokenCacheItem(mAuthRequest.getResource(),","path":"adal/src/main/java/com/microsoft/aad/adal/AcquireTokenSilentHandler.java","position":16,"original_position":16,"commit_id":"087f95519e8c4e7000d95f4dde8317de2ea42ffb","original_commit_id":"087f95519e8c4e7000d95f4dde8317de2ea42ffb","user":{"login":"weijjia","id":1166233,"avatar_url":"https://avatars.githubusercontent.com/u/1166233?v=3","gravatar_id":"","url":"https://api.github.com/users/weijjia","html_url":"https://github.com/weijjia","followers_url":"https://api.github.com/users/weijjia/followers","following_url":"https://api.github.com/users/weijjia/following{/other_user}","gists_url":"https://api.github.com/users/weijjia/gists{/gist_id}","starred_url":"https://api.github.com/users/weijjia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weijjia/subscriptions","organizations_url":"https://api.github.com/users/weijjia/orgs","repos_url":"https://api.github.com/users/weijjia/repos","events_url":"https://api.github.com/users/weijjia/events{/privacy}","received_events_url":"https://api.github.com/users/weijjia/received_events","type":"User","site_admin":false},"body":"@addev-ashish and I talked about this, to make the code more readable, we should wrap the logic here in a separate method instead of having a big block of code in the catch itself. ","created_at":"2016-07-13T20:48:43Z","updated_at":"2016-07-13T20:48:43Z","html_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android/pull/676#discussion_r70705480","pull_request_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/676","_links":{"self":{"href":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/comments/70705480"},"html":{"href":"https://github.com/AzureAD/azure-activedirectory-library-for-android/pull/676#discussion_r70705480"},"pull_request":{"href":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/676"}}},"pull_request":{"url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/676","id":76696229,"html_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android/pull/676","diff_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android/pull/676.diff","patch_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android/pull/676.patch","issue_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues/676","number":676,"state":"open","locked":false,"title":"Add Resiliency Feature","user":{"login":"heidijinxujia","id":16140683,"avatar_url":"https://avatars.githubusercontent.com/u/16140683?v=3","gravatar_id":"","url":"https://api.github.com/users/heidijinxujia","html_url":"https://github.com/heidijinxujia","followers_url":"https://api.github.com/users/heidijinxujia/followers","following_url":"https://api.github.com/users/heidijinxujia/following{/other_user}","gists_url":"https://api.github.com/users/heidijinxujia/gists{/gist_id}","starred_url":"https://api.github.com/users/heidijinxujia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heidijinxujia/subscriptions","organizations_url":"https://api.github.com/users/heidijinxujia/orgs","repos_url":"https://api.github.com/users/heidijinxujia/repos","events_url":"https://api.github.com/users/heidijinxujia/events{/privacy}","received_events_url":"https://api.github.com/users/heidijinxujia/received_events","type":"User","site_admin":false},"body":"Ref. #675 \r\n\r\nThis feature is aim to achieve uninterrupted services access even during an Evo STS outage, server may return ext_expires_in value to indicate the extended lifetime of an access token.\r\n\r\nThe following changes are made to support the resiliency feature:\r\n\r\n1) AuthenticationContext\r\nadded property boolean mExtendedLifetimeEnabled, an explicit switch, which a developer can use to opt in the outage behavior. Set false as default\r\n\r\n2) AuthenticationResult\r\nadded property boolean mIsExtendedLifeTimeToken, to indicate whether the token being returned is a token only valid in terms of extended lifetime. Set false as default. The value will be set to be true only if the stale access token is returned, that is\r\n- [ the server is down (500/503/504) ]\r\n- [ outage mode is on (AuthenticationContext.mExtendedLifetimeEnabled == true) ] \r\n- [ stale access token returned is not expired in the ext_expires_in ]\r\n\r\nadded property Date mExtendedExpiresOn to indicate the date of the extended expire in for the AT. Set null as default\r\n\r\nadded the constructors of AuthenticationResult for new properties\r\n\r\n3) TokenCacheItem\r\nadded property Date mExtendedExpiresOn. While returning the stale token, the mExpiresOn will be valued with mExtendedExpiresOn to minimize impact on client side code\r\n\r\n4) Oauth2\r\nimplemented the retry logic\r\nFor every AcquireToken we should retry once before failing ONLY for 500/503/504. This behavior should be present irrespective of the ExtendedLifeTime flag being set or not making our library more resilient. We should retry once after interval of one second in case of failure.\r\n\r\nIf we retried once and get 500/503/504 response while outage mode is on, a valid stale access token will be returned. Otherwise, an Authentication exception will be thrown.\r\n\r\n5) DefaultTokenCacheStore (token delete logic)\r\nAn access token will be deleted only if the token expires in terms both expires_in and ext_expires_in.","created_at":"2016-07-08T03:09:08Z","updated_at":"2016-07-13T20:48:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc82e556bb289f4cc78b4bdc31ebe65ca4f538dc","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/676/commits","review_comments_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/676/comments","review_comment_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues/676/comments","statuses_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/statuses/087f95519e8c4e7000d95f4dde8317de2ea42ffb","head":{"label":"AzureAD:jj/675","ref":"jj/675","sha":"087f95519e8c4e7000d95f4dde8317de2ea42ffb","user":{"login":"AzureAD","id":2966316,"avatar_url":"https://avatars.githubusercontent.com/u/2966316?v=3","gravatar_id":"","url":"https://api.github.com/users/AzureAD","html_url":"https://github.com/AzureAD","followers_url":"https://api.github.com/users/AzureAD/followers","following_url":"https://api.github.com/users/AzureAD/following{/other_user}","gists_url":"https://api.github.com/users/AzureAD/gists{/gist_id}","starred_url":"https://api.github.com/users/AzureAD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AzureAD/subscriptions","organizations_url":"https://api.github.com/users/AzureAD/orgs","repos_url":"https://api.github.com/users/AzureAD/repos","events_url":"https://api.github.com/users/AzureAD/events{/privacy}","received_events_url":"https://api.github.com/users/AzureAD/received_events","type":"Organization","site_admin":false},"repo":{"id":14703238,"name":"azure-activedirectory-library-for-android","full_name":"AzureAD/azure-activedirectory-library-for-android","owner":{"login":"AzureAD","id":2966316,"avatar_url":"https://avatars.githubusercontent.com/u/2966316?v=3","gravatar_id":"","url":"https://api.github.com/users/AzureAD","html_url":"https://github.com/AzureAD","followers_url":"https://api.github.com/users/AzureAD/followers","following_url":"https://api.github.com/users/AzureAD/following{/other_user}","gists_url":"https://api.github.com/users/AzureAD/gists{/gist_id}","starred_url":"https://api.github.com/users/AzureAD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AzureAD/subscriptions","organizations_url":"https://api.github.com/users/AzureAD/orgs","repos_url":"https://api.github.com/users/AzureAD/repos","events_url":"https://api.github.com/users/AzureAD/events{/privacy}","received_events_url":"https://api.github.com/users/AzureAD/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android","description":"The ADAL SDK for Android gives you the ability to add support for Work Accounts to your application with just a few lines of additional code. This SDK gives your application the full functionality of Microsoft Azure AD, including industry standard protocol support for OAuth2, Web API integration with user level consent, and two factor authentication support.","fork":false,"url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android","forks_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/forks","keys_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/teams","hooks_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/hooks","issue_events_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues/events{/number}","events_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/events","assignees_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/assignees{/user}","branches_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/branches{/branch}","tags_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/tags","blobs_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/statuses/{sha}","languages_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/languages","stargazers_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/stargazers","contributors_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/contributors","subscribers_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/subscribers","subscription_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/subscription","commits_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/contents/{+path}","compare_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/merges","archive_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/downloads","issues_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues{/number}","pulls_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls{/number}","milestones_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/milestones{/number}","notifications_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/labels{/name}","releases_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/releases{/id}","deployments_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/deployments","created_at":"2013-11-26T00:59:05Z","updated_at":"2016-07-04T18:44:21Z","pushed_at":"2016-07-13T00:27:38Z","git_url":"git://github.com/AzureAD/azure-activedirectory-library-for-android.git","ssh_url":"git@github.com:AzureAD/azure-activedirectory-library-for-android.git","clone_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android.git","svn_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android","homepage":"http://www.windowsazure.com/en-us/services/active-directory/","size":33999,"stargazers_count":68,"watchers_count":68,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":45,"forks":54,"open_issues":45,"watchers":68,"default_branch":"master"}},"base":{"label":"AzureAD:dev","ref":"dev","sha":"c0e49877761894c4f08b677c94c891526ef621fb","user":{"login":"AzureAD","id":2966316,"avatar_url":"https://avatars.githubusercontent.com/u/2966316?v=3","gravatar_id":"","url":"https://api.github.com/users/AzureAD","html_url":"https://github.com/AzureAD","followers_url":"https://api.github.com/users/AzureAD/followers","following_url":"https://api.github.com/users/AzureAD/following{/other_user}","gists_url":"https://api.github.com/users/AzureAD/gists{/gist_id}","starred_url":"https://api.github.com/users/AzureAD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AzureAD/subscriptions","organizations_url":"https://api.github.com/users/AzureAD/orgs","repos_url":"https://api.github.com/users/AzureAD/repos","events_url":"https://api.github.com/users/AzureAD/events{/privacy}","received_events_url":"https://api.github.com/users/AzureAD/received_events","type":"Organization","site_admin":false},"repo":{"id":14703238,"name":"azure-activedirectory-library-for-android","full_name":"AzureAD/azure-activedirectory-library-for-android","owner":{"login":"AzureAD","id":2966316,"avatar_url":"https://avatars.githubusercontent.com/u/2966316?v=3","gravatar_id":"","url":"https://api.github.com/users/AzureAD","html_url":"https://github.com/AzureAD","followers_url":"https://api.github.com/users/AzureAD/followers","following_url":"https://api.github.com/users/AzureAD/following{/other_user}","gists_url":"https://api.github.com/users/AzureAD/gists{/gist_id}","starred_url":"https://api.github.com/users/AzureAD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AzureAD/subscriptions","organizations_url":"https://api.github.com/users/AzureAD/orgs","repos_url":"https://api.github.com/users/AzureAD/repos","events_url":"https://api.github.com/users/AzureAD/events{/privacy}","received_events_url":"https://api.github.com/users/AzureAD/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android","description":"The ADAL SDK for Android gives you the ability to add support for Work Accounts to your application with just a few lines of additional code. This SDK gives your application the full functionality of Microsoft Azure AD, including industry standard protocol support for OAuth2, Web API integration with user level consent, and two factor authentication support.","fork":false,"url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android","forks_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/forks","keys_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/teams","hooks_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/hooks","issue_events_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues/events{/number}","events_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/events","assignees_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/assignees{/user}","branches_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/branches{/branch}","tags_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/tags","blobs_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/statuses/{sha}","languages_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/languages","stargazers_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/stargazers","contributors_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/contributors","subscribers_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/subscribers","subscription_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/subscription","commits_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/contents/{+path}","compare_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/merges","archive_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/downloads","issues_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues{/number}","pulls_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls{/number}","milestones_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/milestones{/number}","notifications_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/labels{/name}","releases_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/releases{/id}","deployments_url":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/deployments","created_at":"2013-11-26T00:59:05Z","updated_at":"2016-07-04T18:44:21Z","pushed_at":"2016-07-13T00:27:38Z","git_url":"git://github.com/AzureAD/azure-activedirectory-library-for-android.git","ssh_url":"git@github.com:AzureAD/azure-activedirectory-library-for-android.git","clone_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android.git","svn_url":"https://github.com/AzureAD/azure-activedirectory-library-for-android","homepage":"http://www.windowsazure.com/en-us/services/active-directory/","size":33999,"stargazers_count":68,"watchers_count":68,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":45,"forks":54,"open_issues":45,"watchers":68,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/676"},"html":{"href":"https://github.com/AzureAD/azure-activedirectory-library-for-android/pull/676"},"issue":{"href":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues/676"},"comments":{"href":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/issues/676/comments"},"review_comments":{"href":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/676/comments"},"review_comment":{"href":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/pulls/676/commits"},"statuses":{"href":"https://api.github.com/repos/AzureAD/azure-activedirectory-library-for-android/statuses/087f95519e8c4e7000d95f4dde8317de2ea42ffb"}}}}
{"actor":{"display_login":"weijjia"}}