<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136544#M994</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xueming, Can you shed some light on how I would do this?&amp;nbsp; By extend do you mean implement?&amp;nbsp; Currently in my activity I can get&amp;nbsp; the&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;AuthenticationChallengeResponse handlechallenge(AuthenticationChallenge authenticationChallenge)&amp;nbsp; to work by adding 
this to my activity....&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public class &lt;/SPAN&gt;S1ViewerActivity &lt;SPAN style="color: #000080; font-weight: bold;"&gt;extends &lt;/SPAN&gt;FragmentActivity &lt;SPAN style="color: #000080; font-weight: bold; "&gt;implements &lt;/SPAN&gt;AuthenticationChallengeHandler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when I try to implement DefaultAuthenticationChallengeHandler it will not compile...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public class &lt;/SPAN&gt;S1ViewerActivity &lt;SPAN style="color: #000080; font-weight: bold;"&gt;extends &lt;/SPAN&gt;FragmentActivity &lt;SPAN style="color: #000080; font-weight: bold; "&gt;implements &lt;/SPAN&gt;DefaultAuthenticationChallengeHandler



&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 07:35:55 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-11T07:35:55Z</dc:date>
    <item>
      <title>DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136542#M992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK so I have&amp;nbsp;DefaultAuthenticationChallengeHandler working fine to login to a runtime application with the following code which works great for logging in ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AuthenticationChallengeHandler handler = &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;DefaultAuthenticationChallengeHandler(this);&lt;/P&gt;&lt;P&gt;OAuthConfiguration oAC = &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;OAuthConfiguration(urlLogin, &lt;SPAN style="color: #660e7a;"&gt;Client_ID&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"my-arcgis-app://auth"&lt;/SPAN&gt;, &lt;SPAN style="color: #0000ff;"&gt;129600&lt;/SPAN&gt;); &lt;SPAN style="color: #808080;"&gt;//90 days&lt;BR /&gt;&lt;/SPAN&gt;AuthenticationManager.&lt;SPAN&gt;addOAuthConfiguration&lt;/SPAN&gt;(oAC);&lt;BR /&gt;AuthenticationManager.&lt;SPAN&gt;setAuthenticationChallengeHandler&lt;/SPAN&gt;(&lt;SPAN style="color: #660e7a;"&gt;handler&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the&amp;nbsp;&lt;SPAN&gt;DefaultAuthenticationChallengeHandler works poorly for Web Maps in that the challenge occurs for every single layer in every feature service.&amp;nbsp; Nobody wants to login this many times.&amp;nbsp; When I use a custom login form for feature services I can suppress the multiple logins and use the first login to provide access to the rest of the layers in a feature service.&amp;nbsp; I can do this via a CountDownLatch to suppress the calling thread and wait for the thread firing off the login form for a specific feature service (see code below).&amp;nbsp; The issue I am having is I do like the DefaultAuthenticationChallengeHandler for login to the application because it allows me to not have to handle the username or password myself, but do not like the way it works with feature services.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a way to setup a&amp;nbsp;AuthenticationChallengeResponse listener against the&amp;nbsp;DefaultAuthenticationChallengeHandler so that I could add a CountDownLatch to the default login?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is using a custom login form to access a feature service with CountDownLatch.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AuthenticationManager.setAuthenticationChallengeHandler(this);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Override&lt;/P&gt;&lt;P&gt;public AuthenticationChallengeResponse handleChallenge(AuthenticationChallenge authenticationChallenge) {&lt;BR /&gt; try {&lt;BR /&gt; if (authenticationChallenge.getType() == AuthenticationChallenge.Type.USER_CREDENTIAL_CHALLENGE) {&lt;BR /&gt; if (((Portal) authenticationChallenge.getRemoteResource()).getLoadStatus() == LoadStatus.LOADED) {&lt;BR /&gt; return new AuthenticationChallengeResponse(AuthenticationChallengeResponse.Action.CANCEL,&lt;BR /&gt; authenticationChallenge);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int maxAttempts = 5;&lt;BR /&gt; if (authenticationChallenge.getFailureCount() &amp;gt; maxAttempts) {&lt;BR /&gt; // exceeded maximum amount of attempts. Act like it was a cancel&lt;BR /&gt; Toast.makeText(this, "Exceeded maximum amount of attempts. Please try again!", Toast.LENGTH_LONG).show();&lt;BR /&gt; return new AuthenticationChallengeResponse(AuthenticationChallengeResponse.Action.CANCEL,&lt;BR /&gt; authenticationChallenge);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;String fsURL = authenticationChallenge.getRemoteResource().getUri();&lt;BR /&gt; if (!fsURL.endsWith("/FeatureServer")) {&lt;BR /&gt; if (fsURL.contains("/FeatureServer")) {&lt;BR /&gt; fsURL = fsURL.substring(0, fsURL.indexOf("/FeatureServer") + 14);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;final String fsURLPassIN = fsURL;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (mAgencyCredentials==null) {&lt;BR /&gt; authenticationCounter++;&lt;BR /&gt; DownloadHelper.signal = new CountDownLatch(1);&lt;/P&gt;&lt;P&gt;runOnUiThread(new Runnable() {&lt;BR /&gt; @Override&lt;BR /&gt; public void run() {&lt;BR /&gt; showFSLogin("Credential is required to access " + authenticationChallenge.getRemoteResource().getUri(), fsURLPassIN);&lt;BR /&gt; }&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt; DownloadHelper.signal.await();&lt;BR /&gt; } catch (InterruptedException e) {&lt;BR /&gt; String error = "Interruption handling AuthenticationChallengeResponse: " + e.getMessage();&lt;BR /&gt; Toast.makeText(this, error, Toast.LENGTH_LONG).show();&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; // if credentials were set, return a new auth challenge response with them. otherwise, act like it was a cancel&lt;BR /&gt; if (mAgencyCredentials != null) {&lt;BR /&gt; if (authenticationCounter==0) { //this should be only run once after authentication as this challenge response will hit once for each layer.&lt;BR /&gt; loadMap();&lt;BR /&gt; }&lt;BR /&gt; authenticationCounter++;&lt;BR /&gt; return new AuthenticationChallengeResponse(AuthenticationChallengeResponse.Action.CONTINUE_WITH_CREDENTIAL, mAgencyCredentials);&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;} catch (Exception e){&lt;BR /&gt; e.printStackTrace();&lt;BR /&gt; }&lt;BR /&gt; // no credentials were set, return a new auth challenge response with a cancel&lt;BR /&gt; return new AuthenticationChallengeResponse(AuthenticationChallengeResponse.Action.CANCEL, authenticationChallenge);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2019 18:15:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136542#M992</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-10-07T18:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136543#M993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aaron,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firing multiple challenges for layers hosted on the same server is known issue in our API and&amp;nbsp; has been planned to be fixed in&amp;nbsp; a future release. Sorry for the inconvenient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To workaround this issue and also take advantage of the&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;DefaultAuthenticationChallengeHandler, your custom challenge handler can extend the&amp;nbsp;&lt;SPAN&gt;DefaultAuthenticationChallengeHandler. In&amp;nbsp;handleChallenge() method of your custom challenge handler, you can return super.handleChallenge()&amp;nbsp;where&amp;nbsp;you want to let the&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;DefaultAuthenticationChallengeHandler to take care of the challenges. For other challenges that you want to take care by yourself use your own logic like what you did in the code that you shared in this thread.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; "&gt;Thanks.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2019 20:02:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136543#M993</guid>
      <dc:creator>XuemingWu</dc:creator>
      <dc:date>2019-10-07T20:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136544#M994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xueming, Can you shed some light on how I would do this?&amp;nbsp; By extend do you mean implement?&amp;nbsp; Currently in my activity I can get&amp;nbsp; the&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;AuthenticationChallengeResponse handlechallenge(AuthenticationChallenge authenticationChallenge)&amp;nbsp; to work by adding 
this to my activity....&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public class &lt;/SPAN&gt;S1ViewerActivity &lt;SPAN style="color: #000080; font-weight: bold;"&gt;extends &lt;/SPAN&gt;FragmentActivity &lt;SPAN style="color: #000080; font-weight: bold; "&gt;implements &lt;/SPAN&gt;AuthenticationChallengeHandler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when I try to implement DefaultAuthenticationChallengeHandler it will not compile...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public class &lt;/SPAN&gt;S1ViewerActivity &lt;SPAN style="color: #000080; font-weight: bold;"&gt;extends &lt;/SPAN&gt;FragmentActivity &lt;SPAN style="color: #000080; font-weight: bold; "&gt;implements &lt;/SPAN&gt;DefaultAuthenticationChallengeHandler



&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:35:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136544#M994</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T07:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136545#M995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should probably explain this better.&amp;nbsp; When using this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;AuthenticationChallengeHandler handler =&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000080; background-color: #ffffff; border: 0px; font-weight: bold;"&gt;new&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff;"&gt;DefaultAuthenticationChallengeHandler(this);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;AuthenticationManager.&lt;SPAN&gt;setAuthenticationChallengeHandler&lt;/SPAN&gt;(&lt;SPAN style="color: #660e7a;"&gt;handler&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my custom handler response is never hit (even if I look at it prior to parsing if it is oauth or usercredential).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I use the following below then my custom handler does hit but then not using defaultauthenticationchallengehandler...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;AuthenticationManager.setAuthenticationChallengeHandler(this);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So a little confused as to the steps I can take to get my custom handler response to respond to DefaultAuthenticationChallengeHandler?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2019 22:25:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136545#M995</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-10-07T22:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136546#M996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aaron,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;A href="https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/security/DefaultAuthenticationChallengeHandler.html" rel="nofollow noopener noreferrer" target="_blank"&gt;DefaultAuthenticationChallengeHandler&lt;/A&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp;is a class that implements&amp;nbsp;&lt;SPAN&gt;AuthenticationChallengeHandler interface. You can extend it.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;The following is an example of extending the&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;DefaultAuthenticationChallengeHandler:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;  &lt;SPAN class="keyword token"&gt;private&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;class&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;MyDefaultChallengeHandler&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;extends&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;DefaultAuthenticationChallengeHandler&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;public&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;MyDefaultChallengeHandler&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Activity context&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
      &lt;SPAN class="keyword token"&gt;super&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;context&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

    @Override
    &lt;SPAN class="keyword token"&gt;public&lt;/SPAN&gt; AuthenticationChallengeResponse &lt;SPAN class="token function"&gt;handleChallenge&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;AuthenticationChallenge challenge&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
      &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;challenge&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;getRemoteResource&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;instanceof&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;Portal&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;// let DefaultAuthenticationChallengeHandler handle this challenge &lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;super&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;handleChallenge&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;challenge&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
      &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;// your logic to handle this challenge&lt;/SPAN&gt;
        &lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
      &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The add the following line to the onCreate() of your activity instead of&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;implementing&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;AuthenticationChallengeHandler:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;AuthenticationManager&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;setAuthenticationChallengeHandler&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
          &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;MyDefaultChallengeHandler&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:35:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136546#M996</guid>
      <dc:creator>XuemingWu</dc:creator>
      <dc:date>2021-12-11T07:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136547#M997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xueming, Thanks for the information.&amp;nbsp; That makes more sense.&amp;nbsp; Disregard my last response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2019 22:33:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136547#M997</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-10-07T22:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136548#M998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've followed this post since I'm having a&amp;nbsp;similar problem; I am being authenticated against every FeatureLayer as OP is, but all authentications are working as expected on my Dev portal but&amp;nbsp;only 1 out of 5 times my Production portal.&amp;nbsp; I've attempted to manage the&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;CODE&gt;&lt;SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;"&gt;else&lt;/SPAN&gt; &lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;"&gt;// your logic to handle this challenge&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return new AuthenticationChallengeResponse(  AuthenticationChallengeResponse.Action.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;CONTINUE_WITH_CREDENTIAL &lt;/SPAN&gt;, &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;portalCredential &lt;/SPAN&gt;);
&lt;/CODE&gt;&lt;/CODE&gt;&lt;CODE&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;}&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;by sending over the current credentials of the session where the portalCredential is set&amp;nbsp;directly&amp;nbsp;after the first authentication to Portal.&amp;nbsp; I can tell that there is a token with an expiration two hours in the future, but it always fails with "Token Required" as a result in the&amp;nbsp;LOAD_FAILED check:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;portalMapLayers&lt;/SPAN&gt;.get(&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;).getLoadError().getCause().getLocalizedMessage()&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;P&gt;I'm convinced that the difference between my Dev Portal and my Production Portal is the time it returns a response.&amp;nbsp; Dev has no real load on it, and authenticates immediately.&amp;nbsp; Production takes an obvious fraction of a second, and when it's fast authenticates, but slow it fails and demands a new credential, over and over.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any property that&amp;nbsp;slows down any kind of layer.loadAsync() "timeout" that will let it try to load for a second or two before it assumes it is no longer authenticated?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:36:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136548#M998</guid>
      <dc:creator>AdamStewart</dc:creator>
      <dc:date>2021-12-11T07:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136549#M999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adam,&amp;nbsp; my full implementation code is below...I think CountDownLatch&amp;nbsp;will help you as it allows you to wait for the thread running your login form to run before doing other things.&amp;nbsp; This avoids the login form from popping up multiple times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I establish this variable in a helper class...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public static &lt;/SPAN&gt;CountDownLatch &lt;SPAN style="color: #660e7a;"&gt;signal&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;P&gt;Run this before you run your authentication login form on another thread...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;DownloadHelper.&lt;SPAN style="color: #660e7a;"&gt;signal &lt;/SPAN&gt;= &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;CountDownLatch(&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;);

&lt;/PRE&gt;&lt;P&gt;then right after this (not in the login form thread)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000000;"&gt;DownloadHelper.&lt;/SPAN&gt;&lt;SPAN style="color: #660e7a;"&gt;signal&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;.await();

&lt;/SPAN&gt;The code above forces it to wait for your login thread to to finish meaning you enter your credentials and click OK.&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the login class (my form) when I click the OK button and verify credentials I run this line....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DownloadHelper.&lt;SPAN style="color: #660e7a;"&gt;signal&lt;/SPAN&gt;.countDown();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After this the AuthenticationHandler class will hit for each feature service layer.&amp;nbsp; However at this point there is nothing you need to do and the layers will load correctly unless you have another feature service you are cycling through from a different token authentication service in your web map in which case you would get another prompt and the process would repeat itself.&amp;nbsp; Hope this helps a little.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;android.app.Activity;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;android.support.v4.app.FragmentTransaction;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;android.util.Log;

&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;com.esri.arcgisruntime.data.Geodatabase;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;com.esri.arcgisruntime.portal.Portal;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;com.esri.arcgisruntime.security.AuthenticationChallenge;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;com.esri.arcgisruntime.security.AuthenticationChallengeResponse;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;com.esri.arcgisruntime.security.DefaultAuthenticationChallengeHandler;

&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;java.util.concurrent.CountDownLatch;

&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;gov.s1.s1mobile.downloadsync.DownloadHelper;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;gov.s1.s1mobile.downloadsync.MapExtentDownloadFS;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;gov.s1.s1mobile.downloadsync.MapExtentDownloadWM;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;gov.s1.s1mobile.managelayers.DeleteGDB;
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;gov.s1.s1mobile.map.S1ViewerActivity;

&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import static &lt;/SPAN&gt;gov.s1.s1mobile.map.S1ViewerActivity.&lt;SPAN style="color: #660e7a;"&gt;mAgencyCredentials&lt;/SPAN&gt;;

&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public class &lt;/SPAN&gt;S1AuthenticationChallengeHandler &lt;SPAN style="color: #000080; font-weight: bold;"&gt;extends &lt;/SPAN&gt;DefaultAuthenticationChallengeHandler {
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;public &lt;/SPAN&gt;S1AuthenticationChallengeHandler(Activity context) {
       &lt;SPAN style="color: #000080; font-weight: bold;"&gt;super&lt;/SPAN&gt;(context);
    }

    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;private &lt;/SPAN&gt;InterfaceCommunicator &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;interfaceCommunicator&lt;/SPAN&gt;; &lt;SPAN style="color: #808080;"&gt;// To communicate with parent activity...
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public interface &lt;/SPAN&gt;InterfaceCommunicator {
        &lt;SPAN style="color: #000080; font-weight: bold;"&gt;void &lt;/SPAN&gt;showFSLogin(String errorLabel, String fsURL);
    }

    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;public static &lt;/SPAN&gt;Boolean &lt;SPAN style="color: #660e7a;"&gt;backPressed &lt;/SPAN&gt;= &lt;SPAN style="color: #000080; font-weight: bold;"&gt;false&lt;/SPAN&gt;;  &lt;SPAN style="color: #808080;"&gt;//used to prevent login screen from showing up when user backs out of web map preview window.
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;   &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;private int &lt;/SPAN&gt;&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;authenticationCounter &lt;/SPAN&gt;=  &lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;;

    &lt;SPAN style="color: #808000;"&gt;@Override
&lt;/SPAN&gt;&lt;SPAN style="color: #808000;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public &lt;/SPAN&gt;AuthenticationChallengeResponse handleChallenge(AuthenticationChallenge challenge) {
        &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(challenge.getRemoteResource() &lt;SPAN style="color: #000080; font-weight: bold;"&gt;instanceof &lt;/SPAN&gt;Portal) {   
            &lt;SPAN style="color: #808080;"&gt;// let DefaultAuthenticationChallengeHandler handle this challenge
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;            &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;return super&lt;/SPAN&gt;.handleChallenge(challenge);
        } &lt;SPAN style="color: #000080; font-weight: bold;"&gt;else &lt;/SPAN&gt;{
            &lt;SPAN style="color: #000080; font-weight: bold;"&gt;int &lt;/SPAN&gt;maxAttempts = &lt;SPAN style="color: #0000ff;"&gt;5&lt;/SPAN&gt;;
            &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(challenge.getFailureCount() &amp;gt; maxAttempts) {
                &lt;SPAN style="color: #808080;"&gt;// exceeded maximum amount of attempts. Act like it was a cancel
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;                //Toast.makeText(this, "Exceeded maximum amount of attempts. Please try again!", Toast.LENGTH_LONG).show();
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;                &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;return new &lt;/SPAN&gt;AuthenticationChallengeResponse(AuthenticationChallengeResponse.Action.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;CANCEL&lt;/SPAN&gt;,
                        challenge);
            }

            String fsURL = challenge.getRemoteResource().getUri();

            &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(!fsURL.endsWith(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"/FeatureServer"&lt;/SPAN&gt;)) {
                &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(fsURL.contains(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"/FeatureServer"&lt;/SPAN&gt;)) {
                    &lt;SPAN style="color: #808080;"&gt;//singleLayerPublishedInteger = fsURL.substring(fsURL.lastIndexOf("/") + 1, fsURL.length());
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;                    &lt;/SPAN&gt;fsURL = fsURL.substring(&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;, fsURL.indexOf(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"/FeatureServer"&lt;/SPAN&gt;) + &lt;SPAN style="color: #0000ff;"&gt;14&lt;/SPAN&gt;);
                }
            }

            &lt;SPAN style="color: #000080; font-weight: bold;"&gt;final &lt;/SPAN&gt;String fsURLPassIn = fsURL;
            &lt;SPAN style="color: #808080;"&gt;// create a countdown latch with a count of one to synchronize the dialog
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;            &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="color: #660e7a;"&gt;mAgencyCredentials&lt;/SPAN&gt;==&lt;SPAN style="color: #000080; font-weight: bold;"&gt;null&lt;/SPAN&gt;) { &lt;SPAN style="color: #808080;"&gt;//&amp;amp;&amp;amp; backPressed==false) {
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;                //authenticationCounter++;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;                &lt;/SPAN&gt;DownloadHelper.&lt;SPAN style="color: #660e7a;"&gt;signal &lt;/SPAN&gt;= &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;CountDownLatch(&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;);

                S1ViewerActivity.&lt;SPAN&gt;getS1ViewerActivity&lt;/SPAN&gt;().runOnUiThread(&lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;Runnable() {
                    &lt;SPAN style="color: #808000;"&gt;@Override
&lt;/SPAN&gt;&lt;SPAN style="color: #808000;"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public void &lt;/SPAN&gt;run() {
                       &lt;SPAN style="color: #000080; font-weight: bold;"&gt;try &lt;/SPAN&gt;{
                   
                     &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(!&lt;SPAN style="color: #660e7a;"&gt;backPressed&lt;/SPAN&gt;) {
                        &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(FeatureServiceLogin.&lt;SPAN style="color: #660e7a;"&gt;action&lt;/SPAN&gt;!=&lt;SPAN style="color: #000080; font-weight: bold;"&gt;null&lt;/SPAN&gt;) {
                           &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(FeatureServiceLogin.&lt;SPAN style="color: #660e7a;"&gt;action&lt;/SPAN&gt;.equals(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"downloadWM"&lt;/SPAN&gt;)) {
                              &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(MapExtentDownloadWM.&lt;SPAN&gt;getMapExtentDownloadWM&lt;/SPAN&gt;() != &lt;SPAN style="color: #000080; font-weight: bold;"&gt;null&lt;/SPAN&gt;) {
                                 &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;interfaceCommunicator &lt;/SPAN&gt;= (InterfaceCommunicator) MapExtentDownloadWM.&lt;SPAN&gt;getMapExtentDownloadWM&lt;/SPAN&gt;();
                                 &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;interfaceCommunicator&lt;/SPAN&gt;.showFSLogin(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Credential is required to access " &lt;/SPAN&gt;+ &lt;SPAN style="color: #660e7a;"&gt;challenge&lt;/SPAN&gt;.getRemoteResource().getUri(), &lt;SPAN style="color: #660e7a;"&gt;fsURLPassIn&lt;/SPAN&gt;);
                              }
                           } &lt;SPAN style="color: #000080; font-weight: bold;"&gt;else if &lt;/SPAN&gt;(FeatureServiceLogin.&lt;SPAN style="color: #660e7a;"&gt;action&lt;/SPAN&gt;.equals(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"download"&lt;/SPAN&gt;)) {
                              &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(MapExtentDownloadFS.&lt;SPAN&gt;getMapExtentDownloadFS&lt;/SPAN&gt;() != &lt;SPAN style="color: #000080; font-weight: bold;"&gt;null&lt;/SPAN&gt;) {
                                 &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;interfaceCommunicator &lt;/SPAN&gt;= (InterfaceCommunicator) MapExtentDownloadFS.&lt;SPAN&gt;getMapExtentDownloadFS&lt;/SPAN&gt;();
                                 &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;interfaceCommunicator&lt;/SPAN&gt;.showFSLogin(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Credential is required to access " &lt;/SPAN&gt;+ &lt;SPAN style="color: #660e7a;"&gt;challenge&lt;/SPAN&gt;.getRemoteResource().getUri(), &lt;SPAN style="color: #660e7a;"&gt;fsURLPassIn&lt;/SPAN&gt;);
                              }
                           } &lt;SPAN style="color: #000080; font-weight: bold;"&gt;else if &lt;/SPAN&gt;(FeatureServiceLogin.&lt;SPAN style="color: #660e7a;"&gt;action&lt;/SPAN&gt;.equals(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"delete"&lt;/SPAN&gt;)) {
                              DeleteGDB.&lt;SPAN&gt;getInstance&lt;/SPAN&gt;().showFSLogin(&lt;SPAN style="color: #660e7a;"&gt;fsURLPassIn&lt;/SPAN&gt;);
                              &lt;SPAN style="color: #808080;"&gt;//..showFSLogin("Credential is required to access " + challenge.getRemoteResource().getUri(), fsURLPassIn);
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;                           &lt;/SPAN&gt;}
                        }
                     }
                  } &lt;SPAN style="color: #000080; font-weight: bold;"&gt;catch &lt;/SPAN&gt;(Exception e) {
                     e.printStackTrace();
                  }
                    }
                });

                &lt;SPAN style="color: #000080; font-weight: bold;"&gt;try &lt;/SPAN&gt;{
                    DownloadHelper.&lt;SPAN style="color: #660e7a;"&gt;signal&lt;/SPAN&gt;.await();
                } &lt;SPAN style="color: #000080; font-weight: bold;"&gt;catch &lt;/SPAN&gt;(InterruptedException e) {
                    String error = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Interruption handling AuthenticationChallengeResponse: " &lt;/SPAN&gt;+ e.getMessage();
                    &lt;SPAN style="color: #808080;"&gt;//Toast.makeText(this, error, Toast.LENGTH_LONG).show();
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;                &lt;/SPAN&gt;}
            }
            &lt;SPAN style="color: #808080;"&gt;// if credentials were set, return a new auth challenge response with them. otherwise, act like it was a cancel
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;            &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="color: #660e7a;"&gt;mAgencyCredentials &lt;/SPAN&gt;!= &lt;SPAN style="color: #000080; font-weight: bold;"&gt;null&lt;/SPAN&gt;) {
                &lt;SPAN style="color: #000080; font-weight: bold;"&gt;return new &lt;/SPAN&gt;AuthenticationChallengeResponse(AuthenticationChallengeResponse.Action.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;CONTINUE_WITH_CREDENTIAL&lt;/SPAN&gt;, &lt;SPAN style="color: #660e7a;"&gt;mAgencyCredentials&lt;/SPAN&gt;);
            }


            &lt;SPAN style="color: #808080;"&gt;// your logic to handle this challenge
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;        &lt;/SPAN&gt;}
        &lt;SPAN style="color: #000080; font-weight: bold;"&gt;return null&lt;/SPAN&gt;;
    }
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:36:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136549#M999</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T07:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136550#M1000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So a follow up question here.&amp;nbsp; I have the &lt;SPAN style="background-color: #ffffff;"&gt;defaultauthenticationchallengehandler working but still would like to figure out how to close the Chrome tab.&amp;nbsp; I discovered a way to close the tab by using CustomTabsIntent.&amp;nbsp; However getting this to work with the challenge handler is a bit of a mystery.&amp;nbsp; Anyone have any thoughts on how to do this?&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;androidx.browser.customtabs.CustomTabsIntent;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; &lt;SPAN style="color: #808000;"&gt;@Override
&lt;/SPAN&gt;&lt;SPAN style="color: #808000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public &lt;/SPAN&gt;AuthenticationChallengeResponse handleChallenge(AuthenticationChallenge challenge) {
     &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(challenge.getRemoteResource() &lt;SPAN style="color: #000080; font-weight: bold;"&gt;instanceof &lt;/SPAN&gt;Portal) {
         &lt;SPAN style="color: #808080;"&gt;// let DefaultAuthenticationChallengeHandler handle this challenge
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;         //return super.handleChallenge(challenge);  //How do we incorporate this challenge into CustomTabIntent?
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;String fsURL = challenge.getRemoteResource().getUri();
Uri uri = Uri.&lt;SPAN&gt;parse&lt;/SPAN&gt;(fsURL);
Intent intent = &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;Intent(S1ViewerActivity.&lt;SPAN&gt;getAppContext&lt;/SPAN&gt;(), CustomTabReceiver.&lt;SPAN style="color: #000080; font-weight: bold;"&gt;class&lt;/SPAN&gt;);
PendingIntent pendingIntent = PendingIntent.&lt;SPAN&gt;getBroadcast&lt;/SPAN&gt;(S1ViewerActivity.&lt;SPAN&gt;getAppContext&lt;/SPAN&gt;(), &lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;, intent, &lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;);

CustomTabsIntent.Builder customTabsBuilder = &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;CustomTabsIntent.Builder();
customTabsBuilder.addMenuItem(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Close"&lt;/SPAN&gt;, pendingIntent);
CustomTabsIntent customTabsIntent = customTabsBuilder.build();
customTabsIntent.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;intent&lt;/SPAN&gt;.setPackage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"com.android.chrome"&lt;/SPAN&gt;);
customTabsIntent.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;intent&lt;/SPAN&gt;.addFlags(Intent.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;FLAG_ACTIVITY_NEW_TASK&lt;/SPAN&gt;);
customTabsIntent.launchUrl(S1ViewerActivity.&lt;SPAN&gt;getAppContext&lt;/SPAN&gt;(), uri);

     } &lt;SPAN style="color: #000080; font-weight: bold;"&gt;else &lt;/SPAN&gt;{  //Not a portal attempt but secured feature service
      //Do Stuff related to Feature Service&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;     &lt;/SPAN&gt;}
     &lt;SPAN style="color: #000080; font-weight: bold;"&gt;return null&lt;/SPAN&gt;;
 }&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public class &lt;/SPAN&gt;CustomTabReceiver &lt;SPAN style="color: #000080; font-weight: bold;"&gt;extends &lt;/SPAN&gt;BroadcastReceiver {
   &lt;SPAN style="color: #808000;"&gt;@Override
&lt;/SPAN&gt;&lt;SPAN style="color: #808000;"&gt;   &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public void &lt;/SPAN&gt;onReceive(Context context, Intent intent) {
      Intent myIntent = &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;Intent(context, S1ViewerActivity.&lt;SPAN style="color: #000080; font-weight: bold;"&gt;class&lt;/SPAN&gt;);
      myIntent.addFlags(Intent.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;FLAG_ACTIVITY_CLEAR_TOP&lt;/SPAN&gt;);
      myIntent.addFlags(Intent.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;FLAG_ACTIVITY_NEW_TASK&lt;/SPAN&gt;);
      context.startActivity(myIntent);
   }
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:36:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136550#M1000</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T07:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136551#M1001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alright it is kind of looking like will have to work outside the context of the &lt;SPAN style="background-color: #ffffff;"&gt;defaultauthenticationchallengehandler and handle all this myself from what I can tell.&amp;nbsp; Would have to add into the manifest something like the following...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;data &lt;/SPAN&gt;&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;android&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-weight: bold;"&gt;:scheme=&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"com.packagename:/oauth"&lt;/SPAN&gt;/&amp;gt; instead of using my-arcgis-app and then implement something like on this website...
&lt;A class="link-titled" href="https://medium.com/@ajinkyabadve/do-authentication-in-android-using-custom-chrome-tab-cct-2a0edffc93fd" title="https://medium.com/@ajinkyabadve/do-authentication-in-android-using-custom-chrome-tab-cct-2a0edffc93fd" rel="nofollow noopener noreferrer" target="_blank"&gt;https://medium.com/@ajinkyabadve/do-authentication-in-android-using-custom-chrome-tab-cct-2a0edffc93fd&lt;/A&gt;&amp;nbsp;

The part that is pretty confusing is how to setup the redirect uri etc.  Any thoughts greatly appreciated.&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:36:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136551#M1001</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T07:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: DefaultAuthenticationChallengeHandler adding a AuthenticationChallengeResponse</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136552#M1002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK so looks like in 100.7 DefaultAuthenticationHandler is using Chrome Custom Tabs and it works!&amp;nbsp; So in summary after login the chrome tab for login is no longer open.&amp;nbsp; From the release notes...&lt;A class="link-titled" href="https://developers.arcgis.com/android/latest/guide/release-notes.htm" title="https://developers.arcgis.com/android/latest/guide/release-notes.htm"&gt;Release notes for 100.7.0—ArcGIS Runtime SDK for Android | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;Chrome Custom Tabs—The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959; background-color: #f8f8f8; border-width: 1px 0px 1px 1px; border-style: solid none solid solid; border-color: #efefef initial #efefef #efefef; padding: 0px 0px 0px 0.15rem;"&gt;DefaultAuthenticationChallengeHandler&lt;/SPAN&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;now uses&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A class="" href="https://developer.chrome.com/multidevice/android/customtabs" style="color: #0079c1; background-color: #ffffff; text-decoration: none;" target="_blank"&gt;Chrome Custom Tabs&lt;/A&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;by default in order to prompt users for credentials for OAuth authentication. This provides a better user experience than prompting for credentials in an external browser window. If you still prefer prompting for OAuth credentials in an external browser window, you can disable Chrome Custom Tabs with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #595959; background-color: #f8f8f8; border: 1px solid #efefef; padding: 0px 0.15rem;"&gt;DefaultAuthenticationChallengeHandler.setChromeCustomTabsEnabled&lt;/SPAN&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jan 2020 22:01:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/defaultauthenticationchallengehandler-adding-a/m-p/136552#M1002</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-01-02T22:01:29Z</dc:date>
    </item>
  </channel>
</rss>

