<?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: Authenticate with OAuthApplicationCredential in kotlin android app in Kotlin Maps SDK Questions</title>
    <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/authenticate-with-oauthapplicationcredential-in/m-p/1339702#M248</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/727560"&gt;@FatmaAlzhraa&lt;/a&gt;&amp;nbsp;You can create a class that implements the&amp;nbsp;&lt;A href="https://developers.arcgis.com/kotlin/api-reference/arcgis-maps-kotlin/com.arcgismaps.httpcore.authentication/-arc-g-i-s-authentication-challenge-handler/index.html" target="_blank" rel="noopener"&gt;ArcGISAuthenticationChallengeHandler&lt;/A&gt;&amp;nbsp;interface to handle the authentication.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="kotlin"&gt;class ArcGISCredentialAuthenticationChallengeHandler(
    val createCredential: suspend () -&amp;gt; Result&amp;lt;ArcGISCredential&amp;gt;
) : ArcGISAuthenticationChallengeHandler {
    override suspend fun handleArcGISAuthenticationChallenge(challenge: ArcGISAuthenticationChallenge): ArcGISAuthenticationChallengeResponse {
        val result = createCredential()
        return result.let {
            if (it.isSuccess) {
                ArcGISAuthenticationChallengeResponse.ContinueWithCredential(it.getOrThrow())
            } else {
                ArcGISAuthenticationChallengeResponse.ContinueAndFailWithError(it.exceptionOrNull()!!)
            }
        }
    }
}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now you can use this class to set the&amp;nbsp;&lt;A href="https://developers.arcgis.com/kotlin/api-reference/arcgis-maps-kotlin/com.arcgismaps.httpcore.authentication/-authentication-manager/index.html" target="_blank" rel="noopener"&gt;AuthenticationManager&lt;/A&gt;&amp;nbsp;using your client ID and secret:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="kotlin"&gt;val arcGISChallengeHandler = ArcGISCredentialAuthenticationChallengeHandler {
    OAuthApplicationCredential.create(
        portalUrl = "myPortalURL",
        clientId = "myClientId",
        clientSecret = "myClientSecret",
        tokenExpirationInterval = 0
    )
}
ArcGISEnvironment.authenticationManager.arcGISAuthenticationChallengeHandler = arcGISChallengeHandler

val portal = Portal("myPortalURL", Portal.Connection.Authenticated)
lifecycleScope.launch {
    portal.load().onSuccess {
        println("Success!")
    }.onFailure {
        println("Failed to load portal ${it.printStackTrace()}")
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2023 17:51:52 GMT</pubDate>
    <dc:creator>Shubham_Sharma</dc:creator>
    <dc:date>2023-10-19T17:51:52Z</dc:date>
    <item>
      <title>Authenticate with OAuthApplicationCredential in kotlin android app</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/authenticate-with-oauthapplicationcredential-in/m-p/1339030#M245</link>
      <description>&lt;P&gt;i have&amp;nbsp;&lt;SPAN&gt;"portalUrl"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"clientId"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"clientSecret" and i want&amp;nbsp;&lt;/SPAN&gt; Authenticate with OAuthApplicationCredential in kotlin android app&amp;nbsp;&lt;/P&gt;&lt;P&gt;and store this&amp;nbsp;&lt;SPAN&gt;credential to view map in portal and access&amp;nbsp;services in server&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 10:37:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/authenticate-with-oauthapplicationcredential-in/m-p/1339030#M245</guid>
      <dc:creator>FatmaAlzhraa</dc:creator>
      <dc:date>2023-10-18T10:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Authenticate with OAuthApplicationCredential in kotlin android app</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/authenticate-with-oauthapplicationcredential-in/m-p/1339702#M248</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/727560"&gt;@FatmaAlzhraa&lt;/a&gt;&amp;nbsp;You can create a class that implements the&amp;nbsp;&lt;A href="https://developers.arcgis.com/kotlin/api-reference/arcgis-maps-kotlin/com.arcgismaps.httpcore.authentication/-arc-g-i-s-authentication-challenge-handler/index.html" target="_blank" rel="noopener"&gt;ArcGISAuthenticationChallengeHandler&lt;/A&gt;&amp;nbsp;interface to handle the authentication.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="kotlin"&gt;class ArcGISCredentialAuthenticationChallengeHandler(
    val createCredential: suspend () -&amp;gt; Result&amp;lt;ArcGISCredential&amp;gt;
) : ArcGISAuthenticationChallengeHandler {
    override suspend fun handleArcGISAuthenticationChallenge(challenge: ArcGISAuthenticationChallenge): ArcGISAuthenticationChallengeResponse {
        val result = createCredential()
        return result.let {
            if (it.isSuccess) {
                ArcGISAuthenticationChallengeResponse.ContinueWithCredential(it.getOrThrow())
            } else {
                ArcGISAuthenticationChallengeResponse.ContinueAndFailWithError(it.exceptionOrNull()!!)
            }
        }
    }
}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now you can use this class to set the&amp;nbsp;&lt;A href="https://developers.arcgis.com/kotlin/api-reference/arcgis-maps-kotlin/com.arcgismaps.httpcore.authentication/-authentication-manager/index.html" target="_blank" rel="noopener"&gt;AuthenticationManager&lt;/A&gt;&amp;nbsp;using your client ID and secret:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="kotlin"&gt;val arcGISChallengeHandler = ArcGISCredentialAuthenticationChallengeHandler {
    OAuthApplicationCredential.create(
        portalUrl = "myPortalURL",
        clientId = "myClientId",
        clientSecret = "myClientSecret",
        tokenExpirationInterval = 0
    )
}
ArcGISEnvironment.authenticationManager.arcGISAuthenticationChallengeHandler = arcGISChallengeHandler

val portal = Portal("myPortalURL", Portal.Connection.Authenticated)
lifecycleScope.launch {
    portal.load().onSuccess {
        println("Success!")
    }.onFailure {
        println("Failed to load portal ${it.printStackTrace()}")
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 17:51:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/authenticate-with-oauthapplicationcredential-in/m-p/1339702#M248</guid>
      <dc:creator>Shubham_Sharma</dc:creator>
      <dc:date>2023-10-19T17:51:52Z</dc:date>
    </item>
  </channel>
</rss>

