mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix: credentials issues
This commit is contained in:
committed by
abhi1992002
parent
3cc0be9234
commit
ea13d970ab
@@ -2,7 +2,12 @@ from typing import Literal
|
||||
|
||||
from pydantic import SecretStr
|
||||
|
||||
from backend.data.model import CredentialsField, CredentialsMetaInput, OAuth2Credentials
|
||||
from backend.data.model import (
|
||||
CredentialsField,
|
||||
CredentialsMetaInput,
|
||||
OAuth2Credentials,
|
||||
ProviderName,
|
||||
)
|
||||
from backend.integrations.oauth.twitter import TwitterOAuthHandler
|
||||
from backend.util.settings import Secrets
|
||||
|
||||
@@ -14,7 +19,9 @@ TWITTER_OAUTH_IS_CONFIGURED = bool(
|
||||
# --8<-- [end:TwitterOAuthIsConfigured]
|
||||
|
||||
TwitterCredentials = OAuth2Credentials
|
||||
TwitterCredentialsInput = CredentialsMetaInput[Literal["twitter"], Literal["oauth2"]]
|
||||
TwitterCredentialsInput = CredentialsMetaInput[
|
||||
Literal[ProviderName.TWITTER], Literal["oauth2"]
|
||||
]
|
||||
|
||||
|
||||
# Currently, We are getting all the permission from the Twitter API initally
|
||||
@@ -27,10 +34,8 @@ def TwitterCredentialsField(scopes: list[str]) -> TwitterCredentialsInput:
|
||||
scopes: The authorization scopes needed for the block to work.
|
||||
"""
|
||||
return CredentialsField(
|
||||
provider="twitter",
|
||||
supported_credential_types={"oauth2"},
|
||||
# required_scopes=set(scopes),
|
||||
required_scopes=set(TwitterOAuthHandler.DEFAULT_SCOPES),
|
||||
required_scopes=set(TwitterOAuthHandler.DEFAULT_SCOPES + scopes),
|
||||
description="The Twitter integration requires OAuth2 authentication.",
|
||||
)
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ from typing import ClassVar, Optional
|
||||
|
||||
import requests
|
||||
|
||||
from backend.data.model import OAuth2Credentials
|
||||
from backend.data.model import OAuth2Credentials, ProviderName
|
||||
from backend.integrations.oauth.base import BaseOAuthHandler
|
||||
|
||||
|
||||
class TwitterOAuthHandler(BaseOAuthHandler):
|
||||
PROVIDER_NAME: ClassVar[str] = "twitter"
|
||||
PROVIDER_NAME = ProviderName.TWITTER
|
||||
DEFAULT_SCOPES: ClassVar[list[str]] = [
|
||||
"tweet.read",
|
||||
"tweet.write",
|
||||
|
||||
@@ -27,5 +27,6 @@ class ProviderName(str, Enum):
|
||||
REPLICATE = "replicate"
|
||||
REVID = "revid"
|
||||
SLANT3D = "slant3d"
|
||||
TWITTER = "twitter"
|
||||
UNREAL_SPEECH = "unreal_speech"
|
||||
# --8<-- [end:ProviderName]
|
||||
|
||||
Reference in New Issue
Block a user