Application-only Authentication - Getting Response 408

restapi
oauth
api-access

#1

I am following the documentation to make a application-only authentication but I keep getting a 408 response error code.

I am using python requests to post to https://api.twitter.com/oauth2/token to retrieve the bearer access token.

import requests
headers = {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Authorization': 'Basic <<base64 encoded bearer token credentials>>', 'Content-Length': '29', 'Accept-Encoding': 'gzip', 'grant_type': 'client_credentials'}
requests.post("https://api.twitter.com/oauth2/token", headers=headers)

Please advise.


Ads API 403 'Unauthorized Access"
#2

Are you using the Ads API? The standard API does not return an HTTP 408 response code.

I have a simple shell sample for requesting an app-only token here. You may find it a useful guide.


#3

Thanks for the quick reply. I am able to retrieve the bearer access token now and I am using the Ads API.


#4

Hey Andy,

I am getting a response 403 'Unauthorized Access" when accessing this endpoint. “https://ads-api.twitter.com/1/accounts/:account_id” with the bearer access token. However I am able to retrieve data with this endpoint “https://api.twitter.com/1.1/statuses/user_timeline.json?count=100&screen_name=twitterapi

headers = {'Authorization': 'Bearer <<bearer access token from application-only authentication>>'}
requests.get("https://ads-api.twitter.com/1/accounts/:account_id", headers=headers)


closed #5