OAuthService
Last updated
Was this helpful?
Last updated
Was this helpful?
The OAuthService
object provides a robust interface for managing OAuth authentication and handling authorized requests. It allows developers to create, configure, and execute HTTP requests such as GET, POST, PUT, and DELETE, ensuring secure access to resources. Developers can also retrieve and manage tokens for maintaining session continuity with the OAuth provider.
With methods like createGetRequest()
and executeRequest()
, the service supports constructing and executing customized requests. Token management is facilitated through methods like getAccessToken()
, refreshToken()
, and revokeToken()
, which ensure proper handling of authentication tokens. The service also includes utilities for token expiration checks and obtaining OpenID tokens where supported.
The OAuthService
integrates seamlessly with OAuth flows, enabling developers to work efficiently with access and refresh tokens, authorization URLs, and custom request configurations. For additional details about the , refer to the section of this documentation.
Create a DELETE request.
Create a GET request for a resource.
Create a POST request.
Create a PUT request.
Creates a JSOAuthRequest for with the enum of RequestType (GET, PUT, DELETE, etc) for a resource url.
This is quick method by executing a GET request and returning right away the OAuthResponse So it would be the same as executeRequest(createRequest(RequestType.
Method to execute requests that are made, and configured by #createRequest(Verb,String)
Returns the number of seconds left until the access token expires.
Get the access token currently set on the service.
Return the token lifetime in seconds.
Get the authorization url with some additional parameters.
Obtain the Openid token if it is available.
Return the refresh token.
Checks if the access token is expired.
Obtains a new access token if the OAuth api supports it.
Obtains a new access token based on the refresh token, if the OAuth api supports it.
void
Revoke the provided access token.
void
Configure the oauth service with an access token using the scope that was initially set when creating the service.
void
Configure the oauth service with an access token for the specified scope.
Create a DELETE request.
Parameters
Sample
Create a GET request for a resource.
Parameters
Sample
Create a POST request.
Parameters
Sample
Create a PUT request.
Parameters
Sample
Creates a JSOAuthRequest for with the enum of RequestType (GET, PUT, DELETE, etc) for a resource url.
Parameters
Sample
This is quick method by executing a GET request and returning right away the OAuthResponse So it would be the same as executeRequest(createRequest(RequestType.GET, url))
Parameters
Method to execute requests that are made, and configured by #createRequest(Verb,String)
Parameters
Sample
Returns the number of seconds left until the access token expires.
Sample
Get the access token currently set on the service.
Return the token lifetime in seconds.
Get the authorization url with some additional parameters.
Parameters
Obtain the Openid token if it is available.
Return the refresh token.
Checks if the access token is expired. Returns false if the access token expire information is not set.
Obtains a new access token if the OAuth api supports it.
Sample
Obtains a new access token based on the refresh token, if the OAuth api supports it.
Parameters
Sample
Revoke the provided access token.
Parameters
Returns: void
Configure the oauth service with an access token using the scope that was initially set when creating the service.
Parameters
Returns: void
Configure the oauth service with an access token for the specified scope.
Parameters
Returns: void
resourceURL the url of the resource to be deleted
Returns: the request object
resourceURL the url of the resource which you want to get
Returns: the request object
resourceURL the url where the enclosed entity will be stored
Returns: the request object
resourceURL the url where the enclosed entity will be stored
Returns: the request object
requestType one of the types of plugins.oauth.RequestType
resourceURL the url of the resource you want to access
Returns: a JSOAuthRequest object
resourceURL ;
Returns: the OAuthResponse object
request the JSOAuthRequest object that was created by #createRequest(Verb,String)
Returns: the OAuthResponse object
Returns: seconds left untol the access token expires.
Returns: the access token or null if it was not set
Returns: the token lifetime as it was retrieved by the OAuth provider with the access token
Returns: The authorization URL for initiating the OAuth flow.
params a json containing the parameters and their values e.g. {'param1': 'value1', 'param2': 'value2'}
Returns: the authorization url with the provided parameters appended to the query string.
Returns: the id token, or null if was not set on the service.
Returns: the refresh token or null if it is not present
Returns: true if the access token is expired, false otherwise
Returns: The new access token issued by the authorization server
refreshToken the refresh token string
scope optional, if missing then the default scope configured on the service is used
Returns: The new access token issued by the authorization server
token to revoke
code the authorization code used to request and access token
code the authorization code used to request an access token
scope the scope for which to obtain an access token