I am working on Amazon advertising API. I want to get advertising reports. I am not sure about scope, how I can define scope,
import { HttpClient,ProfileOperation} from '@scaleleap/amazon-advertising-api-sdk'
public static async awsProductAds(store:Store) {
console.log('testing... ads')
try {
const auth = {
accessToken: store.accessToken,
clientId: process.env.CLIENT_ID,
scope: 10000000000 // Use your Profile ID as the value for the management scope
}
const httpClient = new HttpClient('https://advertising-api-eu.amazon.com', auth)
const profileOperation = new ProfileOperation(httpClient);
const data = profileOperation.listProfiles()
console.log(data)
}
catch (e) {
console.log('Amazon Ads Report Error : '+e)
}
}
Without scope, I am getting this error:
UnauthorizedError: HTTP 401 Unauthorized
at apiErrorFactory (E:\amazon_reportcentral\amazon_reports\node_modules@scaleleap\amazon-advertising-api-sdk\src\errors.ts:83:14)
at HttpClient.handleApiResponse (E:\amazon_reportcentral\amazon_reports\node_modules@scaleleap\amazon-advertising-api-sdk\src\http-client.ts:82:28)
at HttpClient.apiRequest (E:\amazon_reportcentral\amazon_reports\node_modules@scaleleap\amazon-advertising-api-sdk\src\http-client.ts:138:17)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'UNAUTHORIZED',
requestId: 'W2TDB73G64XRN1A0DSAB'
}
Please help how I can get amazon advertising reports with nodejs api-sdk