Find answers from the community

s
F
Y
a
P
Updated last month

Credentials

Hey guys - i'm looking to leverage the GoogleDriveReader. The application i'm building is multi-tenanted, and I have a service that indexes each organisations drive folder that they have selected. I've just noticed that this loader requires a credentials.json to index. I already have the users access_token, is there a way to pass this directly without the need to create the credentials file every time? I figure if two people make a request at the same time this file is just going to be overwritten?
L
H
5 comments
Hmmm seems like it needs the files, but you can specify the file names

https://github.com/emptycrown/llama-hub/blob/33155c7ac8b24da316bdfb8d6f1e74746669e554/llama_hub/google_drive/base.py#L22

I wonder if it would work with in-memory files too? Hard to say
Plain Text
    info = {
        "access_token":  result["access_token"],
        "refresh_token": result["refresh_token"],
        "client_id": os.environ['CLIENT_ID'],
        "client_secret": os.environ['CLIENT_SECRET'],
        "scopes": result["scope"],
    }

    # TODO: Update db with new token and refresh token
    creds = Credentials.from_authorized_user_info(info=info)
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
This is working. I create the file each time as it's a requirement but my god this is an awful UX
Feel free to make a PR to improve the loader πŸ˜…
Will do for sure.
Add a reply
Sign up and join the conversation on Discord