Skip to content

Commit

Permalink
fix credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhi1992002 committed Dec 13, 2024
1 parent 9b13e91 commit 6d19825
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
8 changes: 2 additions & 6 deletions autogpt_platform/backend/backend/blocks/slack/_auth.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
from enum import Enum
from typing import Literal
from backend.data.model import OAuth2Credentials
from backend.data.model import OAuth2Credentials,ProviderName,CredentialsField, CredentialsMetaInput
from pydantic import SecretStr

from backend.data.model import CredentialsField, CredentialsMetaInput
from backend.util.settings import Secrets

secrets = Secrets()

SlackProviderName = Literal["slack_bot", "slack_user"]
SlackProviderName = Literal[ProviderName.SLACK_BOT, ProviderName.SLACK_USER]
SlackCredentials = OAuth2Credentials
SlackCredentialsInput = CredentialsMetaInput[SlackProviderName, Literal["oauth2"]]


def SlackCredentialsField(scopes: list[str]) -> SlackCredentialsInput:
return CredentialsField(
provider=["slack_bot","slack_user"],
supported_credential_types={"oauth2"},
description="The Slack integration requires OAuth2 authentication.",
discriminator="type",
discriminator_mapping={
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from typing import TYPE_CHECKING

from backend.integrations.oauth.slack_bot import SlackBotOAuthHandler
from backend.integrations.oauth.slack_user import SlackUserOAuthHandler

from .github import GitHubOAuthHandler
from .google import GoogleOAuthHandler
from .notion import NotionOAuthHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
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 SlackBotOAuthHandler(BaseOAuthHandler):
PROVIDER_NAME: ClassVar[str] = "slack_bot"
PROVIDER_NAME = ProviderName.SLACK_BOT
DEFAULT_SCOPES: ClassVar[list[str]] = [
"chat:write",
"users:read",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
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 SlackUserOAuthHandler(BaseOAuthHandler):
PROVIDER_NAME: ClassVar[str] = "slack_user"
PROVIDER_NAME = ProviderName.SLACK_USER
DEFAULT_SCOPES: ClassVar[list[str]] = [
"chat:write",
"users:read",
Expand Down
2 changes: 2 additions & 0 deletions autogpt_platform/backend/backend/integrations/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class ProviderName(str, Enum):
REPLICATE = "replicate"
REVID = "revid"
SLANT3D = "slant3d"
SLACK_BOT = "slack_bot"
SLACK_USER = "slack_user"
TWITTER = "twitter"
UNREAL_SPEECH = "unreal_speech"
# --8<-- [end:ProviderName]

0 comments on commit 6d19825

Please sign in to comment.