Skip to content

Commit

Permalink
Change to Unauthorized for 401
Browse files Browse the repository at this point in the history
  • Loading branch information
Spartee committed Aug 29, 2024
1 parent f465303 commit 663c987
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions arcade/arcade/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from arcade.client.base import AsyncArcadeClient, BaseResource, SyncArcadeClient
from arcade.client.errors import (

Check warning on line 8 in arcade/arcade/client/client.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/client.py#L7-L8

Added lines #L7 - L8 were not covered by tests
APIStatusError,
AuthenticationError,
BadRequestError,
InternalServerError,
NotFoundError,
PermissionDeniedError,
UnauthorizedError,
)
from arcade.client.schema import (

Check warning on line 16 in arcade/arcade/client/client.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/client.py#L16

Added line #L16 was not covered by tests
AuthProvider,
Expand Down Expand Up @@ -174,7 +174,7 @@ def _execute_request(self, method: str, url: str, **kwargs: Any) -> Any:
e,
{
400: BadRequestError,
401: AuthenticationError,
401: UnauthorizedError,
403: PermissionDeniedError,
404: NotFoundError,
500: InternalServerError,
Expand Down Expand Up @@ -207,7 +207,7 @@ async def _execute_request(self, method: str, url: str, **kwargs: Any) -> Any:
e,
{
400: BadRequestError,
401: AuthenticationError,
401: UnauthorizedError,
403: PermissionDeniedError,
404: NotFoundError,
500: InternalServerError,
Expand Down
2 changes: 1 addition & 1 deletion arcade/arcade/client/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BadRequestError(APIStatusError):
status_code = 400

Check warning on line 34 in arcade/arcade/client/errors.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/errors.py#L34

Added line #L34 was not covered by tests


class AuthenticationError(APIStatusError):
class UnauthorizedError(APIStatusError):

Check warning on line 37 in arcade/arcade/client/errors.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/errors.py#L37

Added line #L37 was not covered by tests
"""401 Unauthorized"""

status_code = 401

Check warning on line 40 in arcade/arcade/client/errors.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/errors.py#L40

Added line #L40 was not covered by tests
Expand Down
6 changes: 3 additions & 3 deletions arcade/arcade/client/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class AuthRequest(BaseModel):
"""The scope(s) needed for authorization."""

Check warning on line 33 in arcade/arcade/client/schema.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/schema.py#L32-L33

Added lines #L32 - L33 were not covered by tests


class AuthState(str, Enum):
"""The state of an authorization request."""
class AuthStatus(str, Enum):

Check warning on line 36 in arcade/arcade/client/schema.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/schema.py#L36

Added line #L36 was not covered by tests
"""The status of an authorization request."""

pending = "pending"
failed = "failed"
Expand All @@ -51,7 +51,7 @@ class AuthResponse(BaseModel):
auth_url: str | None = Field(None, alias="authorizationURL")
"""The URL for the authorization"""

Check warning on line 52 in arcade/arcade/client/schema.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/schema.py#L51-L52

Added lines #L51 - L52 were not covered by tests

state: AuthState
status: AuthStatus
"""Only completed implies presence of a token"""

Check warning on line 55 in arcade/arcade/client/schema.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/schema.py#L54-L55

Added lines #L54 - L55 were not covered by tests

context: ToolContext | None = None

Check warning on line 57 in arcade/arcade/client/schema.py

View check run for this annotation

Codecov / codecov/patch

arcade/arcade/client/schema.py#L57

Added line #L57 was not covered by tests
Expand Down
4 changes: 2 additions & 2 deletions examples/langchain/gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
user_id="example_user_id",
)

if challenge.state != "completed":
if challenge.status != "completed":
print(f"Please visit this URL to authorize: {challenge.auth_url}")
input("Press Enter after you've completed the authorization...")
challenge = client.auth.poll_authorization(challenge.auth_id)
if challenge.state != "completed":
if challenge.status != "completed":
print("Authorization not completed. Please try again.")
exit(1)

Expand Down

0 comments on commit 663c987

Please sign in to comment.