Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3638

Is it possible to use the access token from firebase to authorize YouTube API?

$
0
0

I am trying to post comment on the YouTube video using the YouTube API using ReactJS. But instead of using the gapi for signInWithGoogle, I am using firebase and the access_token returned by firebase.

My code looks something like this.

const url = `https://youtube.googleapis.com/youtube/v3/commentThreads?key=${MY_API_KEY}&part=snippet`const requestOptions = {  method: "POST",  headers: {    Authorization: `Bearer ${ACCESS_TOKEN}`,'Content-Type': 'application/json',    Accept: 'application/json'  }  body: JSON.strigify({"snippet": {"videoId": "[SOME_VIDEO_ID]","topLevelComment": {"snippet": {"textDisplay": "test",        }      }    }  })}fetch(url, requestOptions)  .then(res => res.json())  .then(data => console.log(data))  .catch(err => console.log(err))

But it throws error saying that

{"error": {"code": 401,"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","errors": [            {"message": "Invalid Credentials","domain": "global","reason": "authError","location": "Authorization","locationType": "header"            }        ],"status": "UNAUTHENTICATED"    }}

What is the problem here?


Viewing all articles
Browse latest Browse all 3638

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>