Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting 403 forbidden error while requesting YouTube Analytics API

I'm calling the below end point

https://youtubeanalytics.googleapis.com/v2/reports?

The API was working fine till yesterday.

I linked a new YouTube account to fetch data using the API and I'm getting 403 forbidden error.

I have 2 accessTokens, one which was linked 2 weeks ago, it works fine. But the new accessToken throws 403 forbidden error.

I have checked the scope as well. It's the same while fetching the news accessToken.

How do I fix this?

like image 999
Anirudh Avatar asked Nov 26 '25 02:11

Anirudh


1 Answers

403 forbidden error.

Means that you dont have access to do what you are trying to do. You are trying to access an API endpoint that you dont have access to. Remember YouTube APIs are channel based. This means that you authorize per channel the access.

If you have five YouTube channels and want to see the analytics for each of these channels you will need to authenticate five times and get five different refresh tokens. Each token will only give you access to one channel.

Your issue could be that you are trying to access a channel with an in correct access token.

Timeout

Access tokens expire after one hour you will need to request a new one. If you have requested a refresh token then you can use a refresh token to request a new access token. Remember not to mix them up a refresh token will only give you an access token to access the single account. You will need one for each account you are trying to access.

like image 82
DaImTo Avatar answered Nov 27 '25 15:11

DaImTo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!