Credentials
Credential classes used to perform authenticated interactions with Twitter
TwitterCredentials
Bases: Block
Block used to manage Twitter authentication with tweepy. See Authentication Tokens section of the Keys and Tokens tab of your app, under the Twitter Developer Portal Projects & Apps page at https://developer.twitter.com/en/portal/projects-and-apps.
Attributes:
Name | Type | Description |
---|---|---|
consumer_key |
str
|
This is also known as oauth_consumer_key or API key. |
consumer_secret |
SecretStr
|
This is also known as oauth_consumer_secret or API secret key. |
access_token |
str
|
This is also known as oauth_token. |
access_token_secret |
SecretStr
|
This is also known as oauth_token_secret. |
Example
Load stored Twitter credentials:
from prefect_twitter import TwitterCredentials
twitter_credentials_block = TwitterCredentials.load("BLOCK_NAME")
Source code in prefect_twitter/credentials.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
get_api()
Gets an authenticated Tweepy API.
Returns:
Type | Description |
---|---|
API
|
An authenticated Tweepy API. |
Example
Gets a Tweepy API using consumer and access pairs.
from prefect import flow
from prefect_twitter import TwitterCredentials
@flow
def example_get_api_flow():
consumer_key = "consumer_key"
consumer_secret = "consumer_secret"
access_token = "access_token"
access_token_secret = "access_token_secret"
twitter_credentials = TwitterCredentials(
consumer_key,
consumer_secret,
access_token,
access_token_secret
)
api = twitter_credentials.get_api()
return api
example_get_api_flow()
Source code in prefect_twitter/credentials.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|