kimsia
kimsia2mo 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
rubenf2mo ago
write code (with potentially library) to do the operations that you need helped with the token
kimsia
kimsia2mo 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
kimsia2mo ago
i have tried .get .token ["token"] all not suitable
No description
No description
No description
kimsia
kimsia2mo ago
Script ' Send Email' for gmail | Windmill Hub
How to Send Email for gmail : Send an email using Gmail without any attachments.
rubenf
rubenf2mo ago
["token"] should work in python
kimsia
kimsia2mo ago
but you saw this right?
No description
kimsia
kimsia2mo 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
rubenf2mo ago
will be fixed in next version
kimsia
kimsia2mo 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
rubenf2mo ago
warning is wrong it's just an editor thingy you can ignore it
kimsia
kimsia2mo ago
ok i can finally search emails inside gmail