How to use the aiogoogle.auth.creds.UserCreds function in aiogoogle

To help you get started, we’ve selected a few aiogoogle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github omarryhan / aiogoogle / aiogoogle / auth / managers.py View on Github external
def _build_user_creds_from_res(self, json_res):
        scopes = json_res.pop("scope").split(" ")
        user_creds = UserCreds(**json_res, scopes=scopes)
        # Idk why, but sometimes google returns these json params empty
        user_creds["token_uri"] = (
            self["token_endpoint"] if user_creds.get("token_uri") is None else None
        )
        user_creds["token_info_uri"] = (
            TOKEN_INFO_URI if not user_creds.get("token_info_uri") else None
        )
        user_creds["revoke_uri"] = (
            self["revocation_endpoint"] if not user_creds.get("revoke_uri") else None
        )
        user_creds["expires_at"] = self._get_expires_at(user_creds["expires_in"])
        return user_creds
github omarryhan / aiogoogle / examples / helpers.py View on Github external
from aiogoogle.auth.creds import (
    UserCreds,
    ClientCreds,
    ApiKey,
)  # noqa: F401  imported but unused

try:
    with open("keys.yaml", "r") as stream:
        config = yaml.load(stream, Loader=yaml.FullLoader)
except Exception as e:
    print("Rename _keys.yaml to keys.yaml")
    raise e

email = config["user_creds"]["email"]

user_creds = UserCreds(
    access_token=config["user_creds"]["access_token"],
    refresh_token=config["user_creds"]["refresh_token"],
    expires_at=config["user_creds"]["expires_at"],
)

api_key = ApiKey(config["api_key"])

client_creds = ClientCreds(
    client_id=config["client_creds"]["client_id"],
    client_secret=config["client_creds"]["client_secret"],
    scopes=config["client_creds"]["scopes"],
)