Im trying to subscribe, the login is responding 200 and returning an access token but when trying to subscribe it throws 403, here is the code.
Thanks in advanced.
private createAxiosInstance = async () => {
this.axiosInstance = axios.create({
baseURL: this.baseUrl,
});
const config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
},
};
const body = stringify({
client_id: this.client_id,
client_secret: this.client_secret,
grant_type: 'client_credentials',
});
const {
data: { access_token },
}: AxiosResponse<{ access_token: string; id_token: string }> = await this.axiosInstance.post(
'/auth/realms/main/protocol/openid-connect/token',
body,
config
);
this.axiosInstance.interceptors.request.use(config => {
config.headers.Authorization = `Bearer ${access_token}`;
return config;
});
};
…some code
await this.createAxiosInstance();
const payload_1 = {
planetApiKey: process.env.PLANET_ACCESS_KEY,
name,
collection_id,
input: {
provider,
bounds: {
geometry: aoi,
properties: {
crs: 'http://www.opengis.net/def/crs/EPSG/0/4326',
},
},
data: {
itemType: 'PSScene',
productBundle: 'analytic_udm2',
dataFilter: {
timeRange: {
from,
to,
},
},
harmonizeTo: 'NONE',
},
},
};
const response: AxiosResponse<SubscriptionResponse> = await this.axiosInstance.post(
'api/v1/dataimport/subscriptions',
payload_1
);
await axios.post(`api/v1/dataimport/subscriptions/${response.data.id}/confirm`);
ERROR:
{
status: 403,
reason: “Forbidden”,
message: “Invalid or expired account.”,
code: “COMMON_INSUFFICIENT_PERMISSIONS”,
}