I have the error code 215 too with using command curl.
I do Application-only authentication from this page: https://dev.twitter.com/oauth/application-only
1 step. I have registered my application and create Base64 encoded bearer token credentials: MY_REGISTRATION_KEY
2 step. I enter command:
curl --request POST 'https://api.twitter.com/oauth2/token/' --data 'grant_type=client_credentials' --header 'Authorization':'Basic MY_REGISTRATION_KEY' --header 'Content-Type':'application/x-www-form-urlencoded;charset=UTF-8' -c ~/MNITI/twitter/cookie.txt --connect-timeout 999
Iâve got the token in response:
{"token_type":"bearer","access_token":"MY_TOKEN"}tarik
And Iâve got the id in file cookie.txt:
# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
.twitter.com TRUE / FALSE 1550666430 guest_id v1%3A148759443075881772
**3 step.**Authenticate API requests with the bearer token. My command line:
curl --request GET --cookie "guest_id=v1%3A148759443075881772" 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=100&screen_name=twitterapi' --header 'Authorization:Bearer MY_TOKEN' -I
The response is:
HTTP/1.1 200 OK
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-disposition: attachment; filename=json.json
content-length: 434187
content-type: application/json;charset=utf-8
date: Mon, 20 Feb 2017 11:40:53 GMT
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Mon, 20 Feb 2017 11:40:53 GMT
pragma: no-cache
server: tsa_o
status: 200 OK
strict-transport-security: max-age=631138519
x-access-level: read
x-connection-hash: 12d05179471378f792241127c5fa5958
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-rate-limit-limit: 1500
x-rate-limit-remaining: 1498
x-rate-limit-reset: 1487591350
x-response-time: 200
x-transaction: 006af4d000c5ba96
x-twitter-response-tags: BouncerCompliant
x-xss-protection: 1; mode=block
The line expires: Tue, 31 Mar 1981 05:00:00 GMT is very strangeâŠ
4 step
Search request:
curl " https://api.twitter.com/1.1/search/tweets.json?q=%23MY_SEARCH_REQUEST&result_type=recent
And all⊠I have the error:
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
Help me please!!