I would like to have access to the youtube channel comments, videos, playlist ect..
In my React app I use react-google-login
to get google google token
const login = (props) => {
const clientId = "<OAuthClientIDs>"
const onSuccess = (response) => {
props.onLogin(response.profileObj);
}
const onFailure = (response) => {
console.log(response);
}
return(
<div>
<GoogleLogin
scope="https://www.googleapis.com/auth/youtube"
clientId={clientId}
buttonText="Login"
onSuccess={onSuccess}
onFailure={onFailure}
cookiePolicy={'single_host_origin'}
style={{marginTop:"100px"}}
isSignedIn={true}
/>
</div>
)
}
export default login;
Then with the returned googleid I want to query youtube API
const onLogin = (googleId) => {
setgoogleId(googleId);
}
const logPlayList = () => {
let header = {
headers: {
'Content-Type': 'application/json;charset=UTF-8',
"Authorization": "Bearer " + googleId.googleId,
}
};
axios.get("https://www.googleapis.com/youtube/v3/playlists?part=snippet&mine=true&key=" + googleId", header)
.then(response => { console.log(response.data) })
.catch(error => console.log(error))
}
But when the user wants to login I got Error 403: access_denied response, I dont understand why.
In google cloud I enabled in API library I enabled Youtube Data API V3