I have recently written a Telegram bot in Python which gets the latest video from my YouTube channel and posts it to my related Telegram channel. For that I only need to authorize the YouTube request to get the latest video with an API key. So far so good.
However, today I thought it would be useful if a new video is retrieved is also added to a playlist. For this API endpoint I need to use OAuth2 (which is new to me).
As I understand it, I can make invoke https://www.googleapis.com/auth/youtube' with a PUT request providing the Bearer OAuth2 token. However, I am not sure to provide the secret in this way.
I have the following function:
def addLatestVideoToPlayList(oauth2: str, secret: str, playlistId: str, videoId: str): uri = 'https://www.googleapis.com/auth/youtube' requests.put(uri, params={"Authorization": f"Bearer {oauth2}"}) uri = 'https://www.googleapis.com/youtube/v3/playlistItems' response = requests.post(uri, json={"snippet": {"playlistId": playlistId,"resourceId": {"kind": "youtube#video","videoId": videoId } } }) print(response.json())I am a bit confused, from looking at the API documentation, there is another way to invoke the authorization API with a POST request, but it is unclear to me where to pass the token and where to pass the secret.
Any pointers would be great. Please excuse the naive question.Thank you.