From e8a9ee182b873ba4506e8f8a1fa41e91ca2077fd Mon Sep 17 00:00:00 2001 From: Christopher Gerber Date: Fri, 15 Nov 2024 10:20:38 -0800 Subject: [PATCH] adding bearer token in for twitter client --- .../twitter_langchain/twitter_api_wrapper.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/twitter-langchain/twitter_langchain/twitter_api_wrapper.py b/twitter-langchain/twitter_langchain/twitter_api_wrapper.py index 7e57a6ac3..8f84dc4f0 100644 --- a/twitter-langchain/twitter_langchain/twitter_api_wrapper.py +++ b/twitter-langchain/twitter_langchain/twitter_api_wrapper.py @@ -21,9 +21,8 @@ def validate_environment(cls, values: dict) -> Any: api_key = get_from_dict_or_env(values, "twitter_api_key", "TWITTER_API_KEY") api_secret = get_from_dict_or_env(values, "twitter_api_secret", "TWITTER_API_SECRET") access_token = get_from_dict_or_env(values, "twitter_access_token", "TWITTER_ACCESS_TOKEN") - access_token_secret = get_from_dict_or_env( - values, "twitter_access_token_secret", "TWITTER_ACCESS_TOKEN_SECRET" - ) + access_token_secret = get_from_dict_or_env(values, "twitter_access_token_secret", "TWITTER_ACCESS_TOKEN_SECRET") + bearer_token = get_from_dict_or_env(values, "twitter_bearer_token", "TWITTER_BEARER_TOKEN") try: import tweepy @@ -31,7 +30,7 @@ def validate_environment(cls, values: dict) -> Any: raise ImportError( "Tweepy Twitter SDK is not installed. " -"Please install it with `pip install tweepy`" + "Please install it with `pip install tweepy`" ) from None client = tweepy.Client( @@ -39,6 +38,7 @@ def validate_environment(cls, values: dict) -> Any: consumer_secret=api_secret, access_token=access_token, access_token_secret=access_token_secret, + bearer_token=bearer_token, ) values["client"] = client @@ -46,6 +46,7 @@ def validate_environment(cls, values: dict) -> Any: values["api_secret"] = api_secret values["access_token"] = access_token values["access_token_secret"] = access_token_secret + values["bearer_token"] = bearer_token return values