Skip to content Skip to sidebar Skip to footer

How To Load Client Credentials From Json File For Youtube Analytics Api?

I want to retrieve monetization data from a friend's YouTube channel. I've used the python code below to get the authentication credentials from him, which I then saved to a JSON f

Solution 1:

Solved it myself. I just needed to create the credentials object with this code:

credentials = google.oauth2.credentials.Credentials.from_authorized_user_file(CLIENT_CREDENTIALS_FILE)

Solution 2:

I would just open the file and dump the json into a dictionary.

defread_config(config):
    # config is the name/path to your config file
    with open(config, 'r') as infile:
          config = json.load(infile)

    return(config)


config = read_config("yourfile.json")
id, secret = config["client_id"], config['client_secret"]

Post a Comment for "How To Load Client Credentials From Json File For Youtube Analytics Api?"