Auth

View as Markdown

Auth

While authorizing a Contentstack App, the app requests permissions from the user to perform a set of operations on behalf of the user. The app receives an access token after a user authenticates and authorizes access, then passes it as a credential when it calls the Contentstack APIs.

The Auth class handles user-requested permissions, allowing users to either request for the permission or, once their task is finished, request permission revocations.

Example:

Auth auth = marketplace.authorizations()

.addParam("param1", "value1")

.addHeader("authtoken", ORG_UID);
NameTypeDescription
organizationUid (required)String

UID of the organization

findAuthorizedApp

The findAuthorizedApp method returns a call to retrieve authorized apps.

Example:

Call<ResponseBody> request = auth.findAuthorizedApp().execute();

addParam

The addParam method adds a header with the specified key and value

Specified by:

addParam in interface BaseImplementation

NameTypeDescription
key (required)String

The key of the header to be added

value (required)Object

The value of the header to be added

Throws:

NullPointerException - if the key or value argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 

Auth authorizations = marketplace.authorizations(); 

authorizations.addParam("param1", "value1");

addHeader

The addHeader adds a header with the specified key and value.

Specified by:

addHeader provides support to add custom header to the request

NameTypeDescription
key (required)String

The key of the header to be added

value (required)Object

The value of the header to be added

Throws:

NullPointerException - if the key or value argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 

Auth authorizations = marketplace.authorizations(); 

authorizations.addHeader("key", "value");

addParams

The addParams method adds the specified parameters.

Specified by:

addParams in interface BaseImplementation

NameTypeDescription
params (required)HashMap

The parameters to be added

Throws:

NullPointerException - if the params argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 

Auth authorizations = marketplace.authorizations(); 

HashMap params = new HashMap(); 

authorizations.addParams(params);

addHeaders

The addHeaders method adds the specified parameters.

Specified by:

addHeaders in interface BaseImplementation

NameTypeDescription
headers (required)HashMap

The parameters to be added

Throws:

NullPointerException - if the params argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("api.contentstack.io").build(); 

Auth authorizations = marketplace.authorizations(); 

HashMap params = new HashMap(); 

authorizations.addHeaders(params);