<?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: ArcGIS Online Authentication in Swift Maps SDK Questions</title>
    <link>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1408566#M247</link>
    <description>&lt;P&gt;Thanks for Marvin for information. It will be great if you can just provide a sample project which reproduce the issue so I can debug and see what is going on.&lt;/P&gt;&lt;P&gt;Other important thing to note, SDK is able to display OAuth login page using the&amp;nbsp;&lt;SPAN&gt;SafariViewController only if &amp;nbsp;app has provided an `AGSOAuthConfiguration` instance in&amp;nbsp;&lt;A&gt;OAuthConfigurations&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;property. Can you please check, comment out that code and retry?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nimesh&lt;/P&gt;</description>
    <pubDate>Thu, 11 Apr 2024 15:47:36 GMT</pubDate>
    <dc:creator>NimeshJarecha</dc:creator>
    <dc:date>2024-04-11T15:47:36Z</dc:date>
    <item>
      <title>ArcGIS Online Authentication</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1400257#M235</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;we currently have the issue that we have to avoid the use of safari services. Our goal is to use the os standard browser for authentication. Its working when the AGSAuthenticationManagerDelegates´s function is called where we handle the authentication flow manually and not with "continueWithDefaultHandling".&lt;/P&gt;&lt;P class=""&gt;&lt;EM&gt;&lt;SPAN class=""&gt;func authenticationManager&lt;/SPAN&gt;(&lt;SPAN class=""&gt;_&lt;/SPAN&gt; authenticationManager: AGSAuthenticationManager,&amp;nbsp;&lt;SPAN class=""&gt;didReceive&lt;/SPAN&gt; challenge: AGSAuthenticationChallenge)&lt;/EM&gt;&lt;/P&gt;&lt;P class=""&gt;But if the token expires, a popup appears for login which redirects to a SafariViewController for new authentication. Is there a way to not use the SafariViewController and use the os standard browser instead for a new authentication as well? It seems that the callback function mentioned above is not triggered again for re-authentication.&lt;/P&gt;&lt;P&gt;So what triggers the re-authentication to show a popup and use the SafariViewController?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 09:33:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1400257#M235</guid>
      <dc:creator>mmoosbac94</dc:creator>
      <dc:date>2024-03-25T09:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Authentication</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1401668#M237</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/779132"&gt;@mmoosbac94&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Looks like you are using the 100.x version of the SDK and we encourage posting questions for it on &lt;A href="https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/bd-p/arcgis-runtime-sdk-for-ios-questions" target="_self"&gt;ArcGIS Runtime SDK for iOS Questions.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have implemented the&amp;nbsp;&lt;SPAN&gt;AGSAuthenticationManagerDelegates´s function then it will be called for all challenges. How are you handling the Authentication workflow manually? It will be good if you can post some relevant code. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm assuming you are using the &amp;nbsp;continueWithDefaultHandling on the challenge from the above delegate function. You can check the&amp;nbsp;&lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_authentication_challenge.html#afe6bd19a4e64483f72d661fea2ddc7f4" target="_blank"&gt;type&lt;/A&gt;&amp;nbsp;of the challenge and if it is `AGSAuthenticationChallengeTypeOAuth` then handle it how you are handling it first time.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The SDK uses Apple recommended APIs to display the OAuth login page.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nimesh&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 20:10:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1401668#M237</guid>
      <dc:creator>NimeshJarecha</dc:creator>
      <dc:date>2024-03-27T20:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Authentication</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1401825#M238</link>
      <description>&lt;P&gt;Thanks for the reply! And sorry, next time we will refer to iOS specific thread.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thats part of our code for authentication:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;extension StartViewController: AGSAuthenticationManagerDelegate {

    func authenticationManager(_ authenticationManager: AGSAuthenticationManager, wantsToShow viewController: UIViewController) {
        viewController.modalPresentationStyle = .formSheet
        
        Log.debug("oAuthConfiguration show login")
        present(viewController, animated: true)
    }

    func authenticationManager(_ authenticationManager: AGSAuthenticationManager, wantsToDismiss viewController: UIViewController) {
        Log.debug("oAuthConfiguration close login")
        dismiss(animated: true)
    }

    func authenticationManager(_ authenticationManager: AGSAuthenticationManager,
                               didReceive challenge: AGSAuthenticationChallenge) {
        Log.debug("challenge: \(String(describing: challenge.type.rawValue)), host: \(challenge.authenticatingHost)")
        
        isAuthenticatingUser = true
        showLoginStatus()
        
        Utilities.authenticationChallenge = challenge
        
        if AppSettings.shared.useBrowserAuthentication {
            useBrowserAuthentication(challenge: challenge)
            return
        }

        challenge.continueWithDefaultHandling()
    }

    private func useBrowserAuthentication(challenge: AGSAuthenticationChallenge) {
        AppDelegate.shared.oauth2.authorize() { authParameters, error in
            if let params = authParameters,
               let accessToken = AppDelegate.shared.oauth2.accessToken {
                print("### Authorized! Access token is in `oauth2.accessToken`")
                print("### Authorized! Additional parameters: \(params)")
                challenge.continue(with: AGSCredential(token: accessToken, referer: nil))
                return
            }
            
            challenge.cancel()
            print("### Authorization was canceled or went wrong: \(String(describing: error))")   // error will not be nil
        }
    }
    
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes we are still using the 100.x Version for that app.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when the token expires and we are in-app, then the SafariViewController is shown for re-authentication and no callback function you can see in our code sample is beeing triggered. So anything magical happens in background. But we dont want to use SafariViewController, so actually we want to call e.g.&amp;nbsp;&lt;SPAN class=""&gt;oauth2&lt;/SPAN&gt;.authorize() again to force authentication in os standard browser again. Do you know if the SafariViewController is beeing triggered by the ArcGIS SDK when token expires and if there is any solution to that issue?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 07:33:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1401825#M238</guid>
      <dc:creator>mmoosbac94</dc:creator>
      <dc:date>2024-03-28T07:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Authentication</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1405922#M239</link>
      <description>&lt;P&gt;Thanks for the code and sorry for the delayed response.&lt;/P&gt;&lt;P&gt;Since, `didReceive challenge` function is implemented, SDK should call it for all challenges. The `continueWithDefaultHandling` call is part of that function so may be get called. The OAuth2's access token generated using authorization code flow are valid for 30 minutes so you should see a challenge after 30 minutes.&lt;/P&gt;&lt;P&gt;I'm not sure how `isAuthenticatingUser`, `useBrowserAuthentication`, and `showLoginStatus()` are controlled. So, I would suggest changing code based on challenge type to see if that makes difference. If the challenge &lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_authentication_challenge.html#afe6bd19a4e64483f72d661fea2ddc7f4" target="_blank" rel="noopener"&gt;type&lt;/A&gt; is `OAuth` then call your `useBrowserAuthentication(challenge: challenge)` function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, can you please share the result of this log? Also, you can include challenge's &lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_authentication_challenge.html#a73cc16cde8f69e774376841f17bb4f8d" target="_blank" rel="noopener"&gt;request&lt;/A&gt;&amp;nbsp;in this debug log.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Log.debug("challenge: \(String(describing: challenge.type.rawValue)), host: \(challenge.authenticatingHost)")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hope this helps narrow down the issue.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nimesh&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 17:49:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1405922#M239</guid>
      <dc:creator>NimeshJarecha</dc:creator>
      <dc:date>2024-04-04T17:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Authentication</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1408467#M246</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;That´s exactly the point. The "didReveice challenge" function is not called when token expires. We can´t detect any logs to that. Just for the first regular login we get:&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;authenticationManager(_:didReceive:): challenge: AGSAuthenticationChallengeType(rawValue: 1)&lt;/P&gt;&lt;P class=""&gt;I think you can ignore the mentioned functions "isAuthenticatingUser" etc. because the&amp;nbsp;"didReveice challenge" function is not called anyway. It is like a blackbox to us because we cannot see where the SafariViewController is beeing called and we don´t get any callback to that. Because in case the&amp;nbsp;"didReveice challenge" function is would be called, the "useBrowserAuthentication" function would be executed and we do not use the SafariViewController in any way. Do you know this behaviour that the SafariViewController is beeing shown when token expires for new login?&lt;/P&gt;&lt;P class=""&gt;Regards,&lt;BR /&gt;Marvin&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 12:03:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1408467#M246</guid>
      <dc:creator>mmoosbac94</dc:creator>
      <dc:date>2024-04-11T12:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Authentication</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1408566#M247</link>
      <description>&lt;P&gt;Thanks for Marvin for information. It will be great if you can just provide a sample project which reproduce the issue so I can debug and see what is going on.&lt;/P&gt;&lt;P&gt;Other important thing to note, SDK is able to display OAuth login page using the&amp;nbsp;&lt;SPAN&gt;SafariViewController only if &amp;nbsp;app has provided an `AGSOAuthConfiguration` instance in&amp;nbsp;&lt;A&gt;OAuthConfigurations&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;property. Can you please check, comment out that code and retry?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nimesh&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 15:47:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1408566#M247</guid>
      <dc:creator>NimeshJarecha</dc:creator>
      <dc:date>2024-04-11T15:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Authentication</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1410945#M254</link>
      <description>&lt;P&gt;Thanks for the response and your help! Your information was very helpful. When we remove the "&lt;SPAN&gt;AGSOAuthConfiguration", then the SafariViewController is not be shown. Instead a small popup is shown to login to our ArcGIS Server directly. While checking your solution I discovered another strange thing in our code which leads to the issue that the "didReceive challenge" function was not called when token expires.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;BR /&gt;Marvin&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 14:38:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1410945#M254</guid>
      <dc:creator>mmoosbac94</dc:creator>
      <dc:date>2024-04-17T14:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Authentication</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1411309#M256</link>
      <description>&lt;P&gt;Thanks Marvin for the update. I'm glad to know that your issue is resolved!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nimesh&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 23:42:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/arcgis-online-authentication/m-p/1411309#M256</guid>
      <dc:creator>NimeshJarecha</dc:creator>
      <dc:date>2024-04-17T23:42:53Z</dc:date>
    </item>
  </channel>
</rss>

