How to load client credentials from json file for YouTube Analytics api?

后端 未结 2 1556
[愿得一人]
[愿得一人] 2021-01-03 16:16

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

相关标签:
2条回答
  • 2021-01-03 16:28

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

    def read_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"]
    
    0 讨论(0)
  • 2021-01-03 16:42

    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)
    
    0 讨论(0)
提交回复
热议问题