Class OAuthConfiguration


  • public final class OAuthConfiguration
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      OAuthConfiguration​(java.lang.String portalUrl, java.lang.String clientId, java.lang.String redirectUri)
      Constructs an OAuthConfiguration with the specified portal URL, client ID, and redirect URI.
      OAuthConfiguration​(java.lang.String portalUrl, java.lang.String clientId, java.lang.String redirectUri, int expiration)
      Constructs an OAuthConfiguration with the specified portal URL, client ID, redirect URI and the expiration time for the refresh token.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getClientId()
      Gets the client ID to use for this portal URL.
      java.lang.String getCulture()
      Gets the culture code corresponding to the language to be used on the OAuth login page.
      int getExpiration()
      Gets the expiration interval (in minutes) of the refresh token generated by the OAuth request.
      java.lang.String getPortalUrl()
      Gets the portal URL for which to use this OAuthConfiguration.
      java.lang.String getRedirectUri()
      Gets the redirect URI to use for this portal URL.
      void setCulture​(java.lang.String culture)
      Sets the culture code corresponding to the language to be used on the OAuth login page.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OAuthConfiguration

        public OAuthConfiguration​(java.lang.String portalUrl,
                                  java.lang.String clientId,
                                  java.lang.String redirectUri)
                           throws java.net.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 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:
        java.lang.IllegalArgumentException - if clientId is null
        java.net.MalformedURLException - if the portal URL is non-null and malformed
        Since:
        100.0.0
      • OAuthConfiguration

        public OAuthConfiguration​(java.lang.String portalUrl,
                                  java.lang.String clientId,
                                  java.lang.String redirectUri,
                                  int expiration)
                           throws java.net.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 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:
        java.lang.IllegalArgumentException - if clientId is null
        java.net.MalformedURLException - if the portal URL is non-null and malformed
        Since:
        100.5.0
    • Method Detail

      • getPortalUrl

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

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

        public java.lang.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 interval (in minutes) of the refresh token generated by the OAuth request. The max interval can be overridden by the portal administrator.

        If the expiration interval is not set, then the refresh token is valid for two weeks. If a -1 is passed as the fourth parameter of OAuthConfiguration(String, String, String, int), a permanent refresh Token is generated (if the portal supports permanent refresh tokens).

        Returns:
        the expiration interval of the refresh token in minutes. The value -1 indicates a permanent refresh token.
        Since:
        100.5.0
      • setCulture

        public void setCulture​(java.lang.String culture)
        Sets the culture code corresponding to the language to be used on the OAuth login page.

        The default culture is based on the current culture set on the device/machine. Set it to null if you want to see the OAuth login page in the language corresponding to the culture set in the portal/organization settings.

        The format for culture code is based on a language code and a country code separated by a hyphen. Example: "en-US". For the list of supported cultures see Supported Languages.

        If not explicitly set, the culture used by the device/machine is used. If the culture is not supported by the portal or set to null, OAuth login page will display in the language corresponding to culture specified in the portal/organization settings.

        Parameters:
        culture - the culture code to use, or null to see the OAuth login page in the language corresponding to the culture set in the portal/organization settings
        Since:
        100.9.0
      • getCulture

        public java.lang.String getCulture()
        Gets the culture code corresponding to the language to be used on the OAuth login page.

        The default culture is based on the current culture set on the device/machine.

        The format for culture code is based on a language code and a country code separated by a dash. Example: "en-US". For the list of supported cultures see Supported Languages.

        Returns:
        the culture code currently in use, or null to use the culture set in the portal/organization settings
        Since:
        100.9.0