Class OAuthConfiguration


  • public final class OAuthConfiguration
    extends Object
    Represents a configuration for OAuth access information used by the DefaultAuthenticationChallengeHandler and set on the AuthenticationManager. The client ID and redirect URI will be used when accessing the specified portal URL. If the specified portal URL is null, then the client ID and redirect URI will be used for all portals. Multiple OAuthConfigurations can be added to the AuthenticationManager, each for a separate portal.

    The client ID, along with the redirect URI, will be used to show an OAuth login page on a device-installed browser, which, on Android, is then redirected back to the Activity specified in your manifest. Applications on different portals will require a unique client ID for each portal.

    The redirect URI must be registered to your application in your portal. On Android, the DefaultOAuthIntentReceiver must also be added as an intent filter on the Activity that will receive the redirect intent from the OAuth browser page.

    Note: It is only required to set OAuthConfigurations on the AuthenticationManager when you are using the DefaultAuthenticationChallengeHandler; it is not needed when you are doing custom OAuth workflows using the OAuthLoginManager.

    Since:
    100.0.0
    See Also:
    AuthenticationManager, DefaultAuthenticationChallengeHandler
    • Constructor Detail

      • OAuthConfiguration

        public OAuthConfiguration​(String portalUrl,
                                  String clientId,
                                  String redirectUri)
                           throws MalformedURLException
        Constructs an OAuthConfiguration with the specified portal URL, client ID, and redirect URI. Portal URL may be null to specify that the client ID and redirect URI should be used for all portals, but client ID and redirect URI cannot be null.
        Parameters:
        portalUrl - the portal URL for which to use this client ID and redirect URI, or null to use for all portals
        clientId - the client ID to use for the portal
        redirectUri - the redirect URI to use for the portal
        Throws:
        IllegalArgumentException - if clientId or redirectUri are null
        MalformedURLException - if the portal URL is non-null and malformed
        Since:
        100.0.0
      • OAuthConfiguration

        public OAuthConfiguration​(String portalUrl,
                                  String clientId,
                                  String redirectUri,
                                  int expiration)
                           throws MalformedURLException
        Constructs an OAuthConfiguration with the specified portal URL, client ID, redirect URI and the expiration time for the refresh token. Portal URL may be null to specify that the client ID and redirect URI should be used for all portals, but client ID and redirect URI cannot be null.
        Parameters:
        portalUrl - the portal URL for which to use this client ID and redirect URI, or null to use for all portals
        clientId - the client ID to use for the portal
        redirectUri - the redirect URI to use for the portal
        expiration - the expiration of the refresh token in minutes. The refresh token can be valid for up to 90 days (129600 minutes) or the maximum limit set at the ArcGIS Online organisation level (whichever is minimum). Once the refresh token has expired, the user will have to log in again. For a permanent refresh token (if the portal supports it), use -1
        Throws:
        IllegalArgumentException - if clientId or redirectUri are null
        MalformedURLException - if the portal URL is non-null and malformed
        Since:
        100.5.0
    • Method Detail

      • getPortalUrl

        public String getPortalUrl()
        Gets the portal URL for which to use this OAuthConfiguration.
        Returns:
        the portal URL
        Since:
        100.0.0
      • getClientId

        public String getClientId()
        Gets the client ID to use for this portal URL.
        Returns:
        the client ID
        Since:
        100.0.0
      • getRedirectUri

        public String getRedirectUri()
        Gets the redirect URI to use for this portal URL.
        Returns:
        the redirect URI
        Since:
        100.0.0
      • getExpiration

        public int getExpiration()
        Gets the expiration of the refresh token in minutes.
        Returns:
        the expiration of the refresh token in minutes
        Since:
        100.5.0