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),
|
inputs=create_input_definition(tool),
|
||||||
output=create_output_definition(tool),
|
output=create_output_definition(tool),
|
||||||
requirements=ToolRequirements(
|
requirements=ToolRequirements(
|
||||||
auth=auth_requirement,
|
authorization=auth_requirement,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class ToolAuthRequirement(BaseModel):
|
||||||
class ToolRequirements(BaseModel):
|
class ToolRequirements(BaseModel):
|
||||||
"""The requirements for a tool to run."""
|
"""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."""
|
"""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,
|
func_with_auth_requirement,
|
||||||
{
|
{
|
||||||
"requirements": ToolRequirements(
|
"requirements": ToolRequirements(
|
||||||
auth=ToolAuthRequirement(
|
authorization=ToolAuthRequirement(
|
||||||
oauth2=OAuth2Requirement(
|
oauth2=OAuth2Requirement(
|
||||||
authority="https://example.com/oauth2/auth",
|
authority="https://example.com/oauth2/auth",
|
||||||
scope=["scope1", "scope2"],
|
scope=["scope1", "scope2"],
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@
|
||||||
"oauth2": {
|
"oauth2": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"url": {
|
"authority": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "uri"
|
"format": "uri"
|
||||||
},
|
},
|
||||||
|
|
@ -135,7 +135,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["url"],
|
"required": ["authority"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -144,7 +144,8 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name", "version", "inputs", "output"],
|
"required": ["name", "version", "inputs", "output"],
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ from typing import Annotated
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from googleapiclient.discovery import build
|
from googleapiclient.discovery import build
|
||||||
|
from google.oauth2.credentials import Credentials
|
||||||
|
|
||||||
from arcade.core.schema import ToolContext
|
from arcade.core.schema import ToolContext
|
||||||
from arcade.sdk import tool
|
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."""
|
"""Read emails from a Gmail account and extract plain text content, removing any HTML."""
|
||||||
|
|
||||||
# Call the Gmail API
|
# 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
|
# Request a list of all the messages
|
||||||
result = service.users().messages().list(userId="me").execute()
|
result = service.users().messages().list(userId="me").execute()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue