Missing Authentication Token

Hello All
I am trying to create contract Id using algorand testnet .

async function compileProgram(programSource) {
let encoder = new util.TextEncoder();
let programBytes = encoder.encode(programSource);
let compileResponse = await algodClient.compile(programBytes).do();
let compiledBytes = new Uint8Array(Buffer.from(compileResponse.result, “base64”));
return compiledBytes;
}

When executing below line
let compileResponse = await algodClient.compile(programBytes).do();
Getting error like
status: 403,
headers: {
‘42’: ‘content-length’,
‘Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token’: ‘access-control-allow-headers’,
‘GET,OPTIONS’: ‘access-control-allow-methods’, ‘*’: ‘access-control-allow-origin’,
close: ‘connection’,
‘application/json’: ‘content-type’,
‘Fri, 04 Nov 2022 22:06:18 GMT’: ‘date’,
‘bGLyHHRo4osFXww=’: ‘x-amz-apigw-id’,
MissingAuthenticationTokenException: ‘x-amzn-errortype’,
‘d1cc226b-4f88-48af-852f-2e18c59018fe’: ‘x-amzn-requestid’
},
text: ‘{“message”:“Missing Authentication Token”}’,
ok: false
},
status: 403
}

Below is my algoclient object
let algodServer = “https://testnet-algorand.api.purestake.io/idx2
let algodPort = ‘’;
let algodToken = {
‘X-Api-Key’: “APIKEY from purestack”
}
let algodClient = new algosdk.Algodv2(algodToken, algodServer, algodPort);
Can anyone help please?

Looks like you are building the algodClient object while using the indexer url.

The line “https://testnet-algorand.api.purestake.io/idx2” needs to have the end path as ps2 like here “https://testnet-algorand.api.purestake.io/ps2” to call the algod methods.

Hello Brent
ohh… Yes.
Now it 's working.
Thank you so much.

1 Like