Hi @dipendu_g,
Please find the response below:
- Authentication and Authorization parameters that we need to send with the REST Calls:
To authenticate and authorize REST calls in Campaign v8, you can use OAuth 2.0 authentication. OAuth 2.0 is a widely accepted authentication protocol that enables third-party applications to access protected resources in a secure and standardized way.
To use OAuth 2.0 authentication in Campaign v8, you will need to register your external application as a client in Campaign v8 and obtain an access token that will be used to authorize REST calls. You can then send the access token in the Authorization header of your REST calls.
2. Do we need to create a separate user in ACC and give them necessary permissions?
Yes, you will need to create a separate user in ACC and give them the necessary permissions to access the resources that your API will be calling. You can create a new user in Campaign v8 and assign them the necessary roles and permissions using the Campaign v8 UI or API.
3. How to Authenticate and check Authorization in the JSSP API:
To authenticate and check authorization in the JSSP API, you can use the following JSSP code:
<%@page contentType="application/json" %>
<%
String accessToken = request.getHeader("Authorization").replace("Bearer ", "");
// Verify the access token
if (verifyAccessToken(accessToken)) {
// Handle the API request
...
} else {
// Return an unauthorized response
response.setStatus(401);
}
%>
In this code, we are retrieving the access token from the Authorization header of the request and verifying it using the verifyAccessToken() function. If the access token is valid, we can handle the API request. Otherwise, we return an unauthorized response.
4. Any best practices that you can point me to:
Here are some best practices for creating a custom API in Campaign v8:
- Use OAuth 2.0 authentication to secure your API and protect against unauthorized access.
- Use HTTPS to encrypt communication between your API and external application.
- Use HTTP status codes to provide meaningful responses to the external application.
- Use descriptive error messages to help external applications diagnose issues with the API.
- Follow RESTful API design principles to create a simple and intuitive API that is easy to use and understand.
Here is an example of how to use OAuth 2.0 authentication to authorize REST calls in Campaign v8:
POST /auth/oauth/v2/token HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&
client_id=your_client_id&
client_secret=your_client_secret
This request will return an access token that you can use to authorize subsequent REST calls:
{
"access_token": "your_access_token",
"token_type": "Bearer",
"expires_in": 3600
}