Twitter Oauth2 - Error getting media token

I followed and double-checked the steps to get the carrier token from https://dev.twitter.com/oauth/application-only

I keep getting the following error:
Status: 403 Forbidden {"errors": [{"code": 99, "message": "Failed to verify your credentials", "label": "authenticity_token_error"}]}

I tried passing grant_type = client_credentials in the body as well as the request parameter.

The URL I click on is: https://api.twitter.com/oauth2/token?grant_type=client_credentials

A set of headers: Authorization: Basic [base64encoded (client_key: client_secret)] Content-Type: application / x-www-form-urlencoded; charset = utf-8

I use the poster as a client to make calls.

Can anyone please indicate where I might be wrong.

Many thanks.

+1
source share
1 answer

Send "grant_type = client_credentials" as a payload.

var options = {
    "method":"post",
    "headers": { 
      "Authorization":"Basic " + Utilities.base64Encode(param),
      "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"
    },
    "payload" : "grant_type=client_credentials"
  };

  var response = UrlFetchApp.fetch(TOKEN_URL,options);
0
source

All Articles