Reputation: 11
I was using this program here to post in YouTube: https://github.com/EnriqueStrange/AutomatedYoutube
I have an account with 4 YouTube Channels and I want to be able to automatically post on the different channels. I created 4 different OAuth 2.0 Client IDs, and when running the first the browser opens, I give permission to use the code on one channel and it uploads video fine. But when using the other ID's it just posts in the same channel I originally gave approval instead of asking me permission with the different OAuth ID.
Any idea on how to specify a key for a specific channel?
Created 4 different json files with the OAuth 2.0 Client IDs and expected it would ask permission everytime I ran a new key and link it with a different channel.
Upvotes: 1
Views: 295
Reputation: 117281
You only need one client id. You can authorize the application four times once for each channel. Just store the refresh token. There is no need for a different client.
In the example below you would have a separate 'token.json' for each channel.
if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open('token.json', 'w') as token:
token.write(creds.to_json())
you only need a single 'credentials.json'
Upvotes: 0