kimsia
kimsia4mo ago

[Solved] How to have a script to search for emails inside Gmail using the resource?

Let me describe what i want to do manually and tell me roughly how to do this inside windmill.dev Manual Steps 1. search inside gmail [DigitalOcean] Your 2024-07 invoice is available and it will generate a list of emails (see attached image) 2. i want to iterate through each email 3. and then download each attachment (which is pdf) 4. and then do something to the pdf how to do this inside windmill given that i have the gmail resource installed (see attached), how do i use the resource in my script? I have read this https://www.windmill.dev/docs/core_concepts/resources_and_types#fetching-them-from-within-a-script-by-using-the-wmill-client-in-the-respective-language but i am still unsure how to use this. DO I use a script, flow, or app? all i know is i do gmail_resource = wmill.get_resource("u/kimsia/picturesque_gmail") then i am lost what to do next
Resources and Resource Types | Windmill
Resources are rich objects in JSON that allow to store configuration and credentials.
No description
No description
11 Replies
rubenf
rubenf4mo ago
write code (with potentially library) to do the operations that you need helped with the token
kimsia
kimsiaOP4mo ago
so you mean
gmail_resource = wmill.get_resource("u/kimsia/picturesque_gmail")
# do something with gmail_resource.token
gmail_resource = wmill.get_resource("u/kimsia/picturesque_gmail")
# do something with gmail_resource.token
like that? because when i go to https://hub.windmill.dev/resource_types/38/gmail, all i see is token
kimsia
kimsiaOP4mo ago
i have tried .get .token ["token"] all not suitable
No description
No description
No description
kimsia
kimsiaOP4mo ago
Script ' Send Email' for gmail | Windmill Hub
How to Send Email for gmail : Send an email using Gmail without any attachments.
rubenf
rubenf4mo ago
["token"] should work in python
kimsia
kimsiaOP4mo ago
but you saw this right?
No description
kimsia
kimsiaOP4mo ago
this is my code
def main(query: str):
print(f"Hello World and a warm welcome search_gmail")

gmail_resource = wmill.get_resource("u/kimsia/picturesque_gmail")
oauth_token = gmail_resource["token"]
def main(query: str):
print(f"Hello World and a warm welcome search_gmail")

gmail_resource = wmill.get_resource("u/kimsia/picturesque_gmail")
oauth_token = gmail_resource["token"]
this is the warning
Argument of type "Literal['token']" cannot be assigned to parameter "key" of type "SupportsIndex | slice" in function "__getitem__"
Type "Literal['token']" is incompatible with type "SupportsIndex | slice"
"Literal['token']" is incompatible with protocol "SupportsIndex"
"__index__" is not present
"Literal['token']" is incompatible with "slice"PyrightreportArgumentType
Argument of type "Literal['token']" cannot be assigned to parameter "key" of type "SupportsIndex | slice" in function "__getitem__"
Type "Literal['token']" is incompatible with type "SupportsIndex | slice"
"Literal['token']" is incompatible with protocol "SupportsIndex"
"__index__" is not present
"Literal['token']" is incompatible with "slice"PyrightreportArgumentType
rubenf
rubenf4mo ago
will be fixed in next version
kimsia
kimsiaOP4mo ago
meaning to say the warning is wrong, so i can just use as is? or i have to wait till new version before i can use?
rubenf
rubenf4mo ago
warning is wrong it's just an editor thingy you can ignore it
kimsia
kimsiaOP4mo ago
ok i can finally search emails inside gmail