Parameters Returns Supported Clients Sample Parameters Returns Supported Clients Sample Parameters Returns Supported Clients Sample Parameters Returns Supported Clients Sample Parameters Returns Supported Clients Sample Parameters Returns Supported Clients Sample Parameters Returns Supported Clients Sample Returns Supported Clients Sample Returns Supported Clients Sample Returns Supported Clients Sample Returns Supported Clients Sample Parameters Returns Supported Clients Sample Returns Supported Clients Sample Returns Supported Clients Sample Returns Supported Clients Sample Returns Supported Clients Sample Parameters Supported Clients Sample Parameters Supported Clients Sample Parameters Supported Clients Sample
Mar 20, 2023 10:09
Supported Clients
NGClient
Methods Summary
OAuthRequest
createDeleteRequest(resourceURL)
Create a DELETE request.
OAuthRequest
createGetRequest(resourceURL)
Create a GET request for a resource.
OAuthRequest
createPostRequest(resourceURL)
Create a POST request.
OAuthRequest
createPutRequest(resourceURL)
Create a PUT request.
OAuthRequest
createRequest(requestType, resourceURL)
Creates a JSOAuthRequest for with the enum of RequestType (GET, PUT, DELETE, etc) for a resource url.
OAuthResponse
executeGetRequest(resourceURL)
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.
OAuthResponse
executeRequest(request)
Method to execute requests that are made, and configured by #createRequest(Verb,String)
Number
getAccessExpiresIn()
Returns the number of seconds left until the access token expires.
String
getAccessToken()
Get the access token currently set on the service.
Number
getAccessTokenLifetime()
Return the token lifetime in seconds.
String
getAuthorizationURL()
String
getAuthorizationURL(params)
Get the authorization url with some additional parameters.
String
getIdToken()
Obtain the Openid token if it is available.
String
getRefreshToken()
Return the refresh token.
Boolean
isAccessTokenExpired()
Checks if the access token is expired.
String
refreshToken()
Obtains a new access token if the OAuth api supports it.
void
revokeToken(token)
Revoke the provided access token.
void
setAccessToken(code)
Configure the oauth service with an access token using the scope that was initially set when creating the service.
void
setAccessToken(code, scope)
Configure the oauth service with an access token for the specified scope.
Methods Details
createDeleteRequest(resourceURL)
Create a DELETE request.
String
resourceURL
the url of the resource to be deleted
var putRequest = service.createDeleteRequest("https://graph.microsoft.com/v1.0/me/drive/root:/FolderAA/FileBB.txt:/content");
var response = putRequest.execute();
if (response.getCode() == 204) {
application.output("File was deleted "+response.getBody());
}
else
{
application.output('http status '+response.getCode());
application.output("File could not be deleted: "+response.getBody())
}
createGetRequest(resourceURL)
Create a GET request for a resource.
String
resourceURL
the url of the resource which you want to get
var getRequest = service.createGetRequest("https://api.linkedin.com/v2/me");
getRequest.addHeader("Accept", "application/json");
var response = getRequest.execute();
if (response.getCode() == 200) {
var json = response.getAsJSON();
application.output("Name is "+json.firstName);
}
else
{
application.output("ERROR http status "+response.getCode());
application.output(response.getBody())
}
createPostRequest(resourceURL)
Create a POST request.
String
resourceURL
the url where the enclosed entity will be stored
var postRequest = service.createPostRequest("https://.....");
postRequest.addHeader("Content-Type", "text/plain");
postRequest.addBodyParameter("param1", "value1");
var response = postRequest.execute();
createPutRequest(resourceURL)
Create a PUT request.
String
resourceURL
the url where the enclosed entity will be stored
var putRequest = service.createPutRequest("https://graph.microsoft.com/v1.0/me/drive/root:/FolderAA/FileBB.txt:/content");
putRequest.addHeader("Content-Type", "text/plain");
putRequest.setPayload("ABC");
var response = putRequest.execute();
if (response.getCode() == 201) {
application.output("New file was created "+response.getBody());
}
else
{
application.output("ERROR http status "+response.getCode());
application.output("File could not be created: "+response.getBody())
}
createRequest(requestType, resourceURL)
Creates a JSOAuthRequest for with the enum of RequestType (GET, PUT, DELETE, etc) for a resource url.
enum
requestType
one of the types of plugins.oauth.RequestType
String
resourceURL
the url of the resource you want to access
var request = service.createRequest(plugins.oauth.RequestType.GET, "https://api.linkedin.com/v2/me");
request.addHeader("Accept", "application/json");
var response = request.execute();
if (response.getCode() == 200) {
var json = response.getAsJSON();
application.output("Name is "+json.firstName);
}
else
{
application.output("ERROR http status "+response.getCode());
application.output(response.getBody())
}
executeGetRequest(resourceURL)
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))
String
resourceURL
;
executeRequest(request)
Method to execute requests that are made, and configured by #createRequest(Verb,String)
OAuthRequest
request
the JSOAuthRequest object that was created by #createRequest(Verb,String)
var request = service.createRequest(plugins.oauth.RequestType.GET, "https://api.linkedin.com/v2/me");
request.addHeader("Accept", "application/json");
var response = service.executeRequest(request);
if (response.getCode() == 200) {
var json = response.getAsJSON();
application.output("Name is "+json.firstName);
}
else
{
application.output("ERROR http status "+response.getCode());
application.output(response.getBody())
}
getAccessExpiresIn()
Returns the number of seconds left until the access token expires.
var seconds = service.getAccessExpiresIn();
if (seconds < 60)
{
application.output("The access token is going to expire in less than 1 minute! Use service.refreshToken() to get a new one");
}
else
{
application.output("Make some requests");
}
getAccessToken()
Get the access token currently set on the service.
getAccessTokenLifetime()
Return the token lifetime in seconds.
getAuthorizationURL()
getAuthorizationURL(params)
Get the authorization url with some additional parameters.
Object
params
a json containing the parameters and their values
e.g. {'param1': 'value1', 'param2': 'value2'}
getIdToken()
Obtain the Openid token if it is available.
getRefreshToken()
Return the refresh token.
isAccessTokenExpired()
Checks if the access token is expired. Returns false if the access token expire information is not set.
refreshToken()
Obtains a new access token if the OAuth api supports it.
accessToken = service.refreshToken();
revokeToken(token)
Revoke the provided access token.
String
token
to revoke
setAccessToken(code)
Configure the oauth service with an access token using the scope that was initially set when creating the service.
String
code
the authorization code used to request and access token
setAccessToken(code, scope)
Configure the oauth service with an access token for the specified scope.
String
code
the authorization code used to request an access token
String
scope
the scope for which to obtain an access token