Hi,

My developer account was approved last week, and I subscribed a premium access for extracting the full archive data. The environment settings, app key and secret were correctly showing up there. The program shows nothing wrong but says that the account has no authorization to the resource.

Could twitter staff check my account or app settings? It has been two days since the purchase of premium but can do nothing with this no authorization. Really frustrated with purchasing not working service. My account is @michelle17058

Looking forward for your help with my account,
Thank you!

I can understand you must be frustrated - apologies for that.

Can you share how you’re trying to call the API (without sharing your consumer key or secret). Are you using a bearer token to call the full archive search endpoint correctly?

Hi Andy,

Thanks for your understanding.

I tried Bearer, and it says invalid or expired token. I also tried key and secret using the yaml file and it gives 403, authentication succeeded but the account is not authorized to use this resource.

Here is the yaml file content:

search_tweets_premium:

account_type: premium

endpoint: https://api.twitter.com/1.1/tweets/search/fullarchive/dev.json

consumer_key:

consumer_secret:

And here’s the code to use this yaml file:

from searchtweets import ResultStream, gen_rule_payload, load_credentials

premium_search_args = load_credentials(“twitter_keys.yaml”,
yaml_key=“search_tweets_premium”,
env_overwrite=False)

rule = gen_rule_payload(“bitcoin”, results_per_call=100)
print(rule)

from searchtweets import collect_results

tweets = collect_results(rule,
max_results=100,
result_stream_args=premium_search_args) # this part gives error

[print(tweet.all_text, end=’\n\n’) for tweet in tweets[0:10]];
[print(tweet.created_at_datetime) for tweet in tweets[0:10]];
[print(tweet.generator.get(“name”)) for tweet in tweets[0:10]];

Thanks.

Can you try generating a bearer token from your consumer key and secret using a script like this one, and then replacing the consumer token and secret with a bearer token in your yaml file?

Hi Andy,

I tried generating the bearer token using this code but it says the token is expired or invalid.
Which part do you think may have a problem?

Trying 104.244.42.194…
Connected to api.twitter.com (104.244.42.194) port 443 (#0)
ALPN, offering http/1.1
Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
successfully set certificate verify locations:
CAfile: /home/danzhu/python/anaconda3/ssl/cacert.pem
CApath: none
TLSv1.2 (OUT), TLS header, Certificate Status (22):
TLSv1.2 (OUT), TLS handshake, Client hello (1):
TLSv1.2 (IN), TLS handshake, Server hello (2):
TLSv1.2 (IN), TLS handshake, Certificate (11):
TLSv1.2 (IN), TLS handshake, Server key exchange (12):
TLSv1.2 (IN), TLS handshake, Server finished (14):
TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
TLSv1.2 (OUT), TLS change cipher, Client hello (1):
TLSv1.2 (OUT), TLS handshake, Finished (20):
TLSv1.2 (IN), TLS change cipher, Client hello (1):
TLSv1.2 (IN), TLS handshake, Finished (20):
SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
ALPN, server accepted to use http/1.1
Server certificate:
subject: C=US; ST=California; L=San Francisco; O=Twitter, Inc.; OU=Twitter Security; CN=api.twitter.com
start date: Jun 29 00:00:00 2016 GMT
expire date: Sep 19 12:00:00 2019 GMT
subjectAltName: host “api.twitter.com” matched cert’s “api.twitter.com
issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
SSL certificate verify ok.
POST /oauth2/token HTTP/1.1
Host: api.twitter.com
User-Agent: curl/7.49.0
Accept: /
Authorization: Basic dFBucGtQdXk4cDFROEt6c1c0RXlhSVRJaDpjdTNoUVNPekRpNVMzaW4xNFRKaEl0djhqbGZ4bU9uUllzTkdNWFJ0TTRhUDlYQk81cg==
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 29
upload completely sent off: 29 out of 29 bytes
< 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: 153
< content-type: application/json;charset=utf-8
< date: Fri, 08 Jun 2018 05:11:17 GMT
< expires: Tue, 31 Mar 1981 05:00:00 GMT
< last-modified: Fri, 08 Jun 2018 05:11:17 GMT
< ml: S
< pragma: no-cache
< server: tsa_a
< set-cookie: personalization_id=“v1_LHNnRKme/hf+mO2RSK15sA==”; Expires=Sun, 07 Jun 2020 05:11:17 GMT; Path=/; Domain=.twitter.com
< set-cookie: guest_id=v1%3A152843467746996227; Expires=Sun, 07 Jun 2020 05:11:17 GMT; Path=/; Domain=.twitter.com
< status: 200 OK
< strict-transport-security: max-age=631138519
< x-connection-hash: 4ca2a057c6063d842b34d66bf16c26c3
< x-content-type-options: nosniff
< x-frame-options: DENY
< x-response-time: 13
< x-transaction: 00e9365900d67084
< x-tsa-request-body-time: 0
< x-twitter-response-tags: BouncerCompliant
< x-ua-compatible: IE=edge,chrome=1
< x-xss-protection: 1; mode=block; report=https://twitter.com/i/xss_report
<
Connection #0 to host api.twitter.com left intact
{“token_type”:“bearer”,“access_token”:“AAAAA…”}

Thank you.

Try curl (here’s one looking at the first month of the year for bitcoin), to make sure you have access:
*note sandbox access will only have access for maxResults=100

curl "https://api.twitter.com/1.1/tweets/search/fullarchive/dev.json?maxResults=500&query=bitcoin&fromDate=201801010000&toDate=201802010000" -H "Authorization: Bearer AAAAAAAAAxxxxxxxxxxxcE3F"

I already purchased the premium rather than sandbox which I should have the access, right? And I have the maximum as 100, even not exceeding the sandbox limitation.

Hi @michelle17058 I was out last week so was unable to follow up - are you still having an authentication problem?

Hi Andy,

Thank you for your reply.

Yes, it is still not working.

Michelle

@michelle17058

Did you get your Bearer token?
Can you check that the application credentials that you used to create your bearer token are set up in your environments here: https://developer.twitter.com/en/account/environments?

Hi Emily,

I did create the beater token using the consumer key and secret, but when I use it, it says the token is expired or in valid. Currently, the environment shows as Premium / Full Archive for this app.

It seems like I have not really been added to the developer account or premium service though it shows I have the environment.

Thank you.