Class OAuthTokenCredentialRequest

java.lang.Object
com.esri.arcgisruntime.security.OAuthTokenCredentialRequest

public final class OAuthTokenCredentialRequest extends Object
Performs a request to retrieve an OAuthTokenCredential. Provided a URL, client ID, redirect URI (optional), expiration (optional) and authorization code, access and refresh tokens will be fetched and returned as an OAuthTokenCredential. The general workflow is:
  1. Call getAuthorizationUrl(String, String, String, long) to build the URL for showing the OAuth login page.
  2. Start an intent to show the URL in a device-installed web browser, which will redirect back to the app.
  3. Pass the returned authorization code to the OAuthTokenCredentialRequest constructor.
  4. Call executeAsync() to fetch the OAuthTokenCredential.
Since:
100.0.0
  • Constructor Details

    • OAuthTokenCredentialRequest

      public OAuthTokenCredentialRequest(String baseUrl, RequestConfiguration requestConfiguration, String clientId, String redirectUri, String authCode)
      Instantiates a new OAuthTokenCredentialRequest with the specified parameters to request an OAuthTokenCredential.
      Parameters:
      baseUrl - the base URL of the portal
      requestConfiguration - the request configuration to apply to this request
      clientId - the client ID that was registered for this application
      redirectUri - the redirect URI to follow during the authorization workflow (optional)
      authCode - the authorization code retrieved from the authorization URL
      Since:
      100.0.0
    • OAuthTokenCredentialRequest

      public OAuthTokenCredentialRequest(String baseUrl, RequestConfiguration requestConfiguration, String clientId, String redirectUri, String authCode, long expiration)
      Instantiates a new OAuthTokenCredentialRequest with the specified parameters to request an OAuthTokenCredential. The refresh token can be valid for 90 days or the maximum limit set at the ArcGISOnline organisation level (whichever is minimum). For a permanent refresh token (if the portal supports it), use -1. Make sure to specify the same expiration of refresh token which was used in the call to getAuthorizationUrl(String, String, String, long) to build the URL for showing the OAuth login page.
      Parameters:
      baseUrl - the base URL of the portal
      requestConfiguration - the request configuration to apply to this request
      clientId - the client ID that was registered for this application
      redirectUri - the redirect URI to follow during the authorization workflow (optional)
      authCode - the authorization code retrieved from the authorization URL
      expiration - the desired expiration of the refresh token in minutes, 0 for default expiry time or -1 for a permanent refresh token
      Since:
      100.5.0
    • OAuthTokenCredentialRequest

      public OAuthTokenCredentialRequest(String baseUrl, RequestConfiguration requestConfiguration, String clientId, String redirectUri, String authCode, long expiration, String codeVerifier, String codeChallenge, String codeChallengeMethod)
      Instantiates a new OAuthTokenCredentialRequest with the specified parameters to request an OAuthTokenCredential. The refresh token can be valid for 90 days or the maximum limit set at the ArcGISOnline organisation level (whichever is minimum). For a permanent refresh token (if the portal supports it), use -1. Make sure to specify the same expiration of refresh token which was used in the call to getAuthorizationUrl(String, String, String, long) to build the URL for showing the OAuth login page.
      Parameters:
      baseUrl - the base URL of the portal
      requestConfiguration - the request configuration to apply to this request
      clientId - the client ID that was registered for this application
      redirectUri - the redirect URI to follow during the authorization workflow (optional)
      authCode - the authorization code retrieved from the authorization URL
      expiration - the desired expiration of the refresh token in minutes, 0 for default expiry time or -1 for a permanent refresh token
      codeVerifier - the PKCE code verifier string, or null if PKCE is not supported by the Portal
      codeChallenge - the PKCE code challenge string, or null if PKCE is not supported by the Portal
      codeChallengeMethod - the PKCE code challenge method string, or null if PKCE is not supported by the Portal
      Since:
      100.12.0
  • Method Details

    • executeAsync

      public ListenableFuture<OAuthTokenCredential> executeAsync()
      Asynchronous computation to execute the request. The result is an OAuthTokenCredential.
      Returns:
      a ListenableFuture for tracking when the computation is done and getting the result
      Since:
      100.0.0
    • getAuthorizationUrl

      public static String getAuthorizationUrl(String baseUrl, String clientId, String redirectUri, long expiration)
      Returns the full URL for showing the OAuth login page and obtaining an authorization code. Use this method, in preference to the overload that takes an extra parameter 'culture', to use the current culture set on the device/machine.

      The refresh token can be valid for 90 days or the maximum limit set at the ArcGISOnline organisation level (whichever is minimum). For a permanent refresh token (if the portal supports it), use -1. Make sure to specify the same expiration of refresh token when instantiating a new OAuthTokenCredentialRequest(String, RequestConfiguration, String, String, String, long).

      Parameters:
      baseUrl - the base URL of the portal
      clientId - the registered client ID of this application
      redirectUri - the redirect URI to follow throughout the authorization workflow, or null to use the default
      expiration - the desired expiration of the refresh token in minutes, 0 for default expiry time or -1 for a permanent refresh token
      Returns:
      the full URL for the authorization page
      Since:
      100.0.0
    • getAuthorizationUrl

      public static String getAuthorizationUrl(String baseUrl, String clientId, String redirectUri, long expiration, String culture)
      Returns the full URL for showing the OAuth login page and obtaining an authorization code. Use this method, in preference to the overload that does not take a 'culture' parameter, if you do not want to use the current culture set on the device/machine.

      The refresh token can be valid for 90 days or the maximum limit set at the ArcGISOnline organisation level (whichever is minimum). For a permanent refresh token (if the portal supports it), use -1. Make sure to specify the same expiration of refresh token when instantiating a new OAuthTokenCredentialRequest(String, RequestConfiguration, String, String, String, long).

      Parameters:
      baseUrl - the base URL of the portal
      clientId - the registered client ID of this application
      redirectUri - the redirect URI to follow throughout the authorization workflow, or null to use the default
      expiration - the desired expiration of the refresh token in minutes, 0 for default expiry time or -1 for a permanent refresh token
      culture - the culture code corresponding to the language to be used on the OAuth login page, for example "en-US", or null to allow the language to be determined by the portal/organization settings
      Returns:
      the full URL for the authorization page
      Since:
      100.9.0
    • getAuthorizationUrl

      public static String getAuthorizationUrl(String baseUrl, String clientId, String redirectUri, long expiration, String culture, String codeChallenge, String codeChallengeMethod)
      Returns the full URL for showing the OAuth login page and obtaining an authorization code. Use this method, in preference to the overload that does not take a 'culture' parameter, if you do not want to use the current culture set on the device/machine.

      The refresh token can be valid for 90 days or the maximum limit set at the ArcGISOnline organisation level (whichever is minimum). For a permanent refresh token (if the portal supports it), use -1. Make sure to specify the same expiration of refresh token when instantiating a new OAuthTokenCredentialRequest(String, RequestConfiguration, String, String, String, long).

      Parameters:
      baseUrl - the base URL of the portal
      clientId - the registered client ID of this application
      redirectUri - the redirect URI to follow throughout the authorization workflow, or null to use the default
      expiration - the desired expiration of the refresh token in minutes, 0 for default expiry time or -1 for a permanent refresh token
      culture - the culture code corresponding to the language to be used on the OAuth login page, for example "en-US", or null to allow the language to be determined by the portal/organization settings
      codeChallenge - the PKCE code challenge string, or null if PKCE is not supported by the Portal
      codeChallengeMethod - the PKCE code challenge method string, or null if PKCE is not supported by the Portal
      Returns:
      the full URL for the authorization page
      Since:
      100.12.0