Fix authorized tools (#14)
A few quick fixes while testing the gmail tool with the real Engine: - Renamed `tool.requirements.auth` to `authorization` -- Engine already used `authorization` - Fixed the credentials initializer in the gmail tool
This commit is contained in:
parent
35baaf0dc8
commit
d90101ea70
5 changed files with 9 additions and 7 deletions
|
|
@ -193,7 +193,7 @@ class ToolCatalog(BaseModel):
|
|||
inputs=create_input_definition(tool),
|
||||
output=create_output_definition(tool),
|
||||
requirements=ToolRequirements(
|
||||
auth=auth_requirement,
|
||||
authorization=auth_requirement,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class ToolAuthRequirement(BaseModel):
|
|||
class ToolRequirements(BaseModel):
|
||||
"""The requirements for a tool to run."""
|
||||
|
||||
auth: Union[ToolAuthRequirement, None] = None
|
||||
authorization: Union[ToolAuthRequirement, None] = None
|
||||
"""The authorization requirements for the tool, if any."""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ def func_with_complex_return() -> list[dict[str, str]]:
|
|||
func_with_auth_requirement,
|
||||
{
|
||||
"requirements": ToolRequirements(
|
||||
auth=ToolAuthRequirement(
|
||||
authorization=ToolAuthRequirement(
|
||||
oauth2=OAuth2Requirement(
|
||||
authority="https://example.com/oauth2/auth",
|
||||
scope=["scope1", "scope2"],
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@
|
|||
"oauth2": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"url": {
|
||||
"authority": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
|
|
@ -135,7 +135,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"required": ["url"],
|
||||
"required": ["authority"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
|
|
@ -144,7 +144,8 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["name", "version", "inputs", "output"],
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import Annotated
|
|||
|
||||
from bs4 import BeautifulSoup
|
||||
from googleapiclient.discovery import build
|
||||
from google.oauth2.credentials import Credentials
|
||||
|
||||
from arcade.core.schema import ToolContext
|
||||
from arcade.sdk import tool
|
||||
|
|
@ -23,7 +24,7 @@ async def get_emails(
|
|||
"""Read emails from a Gmail account and extract plain text content, removing any HTML."""
|
||||
|
||||
# Call the Gmail API
|
||||
service = build("gmail", "v1", credentials=context.authorization.token)
|
||||
service = build("gmail", "v1", credentials=Credentials(context.authorization.token))
|
||||
|
||||
# Request a list of all the messages
|
||||
result = service.users().messages().list(userId="me").execute()
|
||||
|
|
|
|||
Loading…
Reference in a new issue