1

How can i pass Bearer token with post method. I tried with postman but getting this response "Error: Unauthorized Access. Request is not authorized"

            await turnContext.sendActivity(`${await requestify.request(url, {
                method: 'POST',
                body: data,
                dataType: 'json',
                auth:{
                    "Bearer":access_token // token
                }
            }).then(async function (res) {
                console.log(res.body);
                return res.body;
            })}`);
kiran
  • 11
  • 1
  • 6

2 Answers2

1

You need to add Bearer as prefix to your token:

 await turnContext.sendActivity(`${await requestify.request(url, {
                method: 'POST',
                body: data,
                dataType: 'json',
                auth:{
                    `Bearer ${access_token}` // token
                }
            }).then(async function (res) {
                console.log(res.body);
                return res.body;
            })}`);
Harish Soni
  • 1,796
  • 12
  • 27
1

Looking at the documentation the auth property is used for basic auth only, so just add the Authorization header manually

await requestify.request(url, {
    method: 'POST',
    body: data,
    dataType: 'json',
    headers :{
        Authorization:"Bearer " + access_token // token
    }
})
George
  • 6,630
  • 2
  • 29
  • 36