Unable to get CPM data from Youtube Analytics account - youtube-analytics-api

I'm unable to get CPM data from my Youtube reports:
I'm getting:
{
"error": {
"code": 403,
"message": "Forbidden",
"errors": [
{
"message": "Forbidden",
"domain": "global",
"reason": "forbidden"
}
]
}
}
I don't even know where to begin to debug this, and I haven't found anything online.
I'm just trying to curl the endpoint, mirroring this: HERE
Notice that once you finish the oauth process, User will see
"You do not have permission to execute this method." and the 403
Also, Notice if you remove 'CPM' from the list of metrics, this will work.
Example:
curl --header "Authorization: Bearer _____access_token____" -e "https://developers.google.com" https://content-youtubeanalytics.googleapis.com/v2/reports\?endDate\=2014-06-30\&ids\=channel%3D%3DMINE\&metrics\=cpm\&startDate\=2014-05-01\&key\=_____api_key____
I'm getting the refresh token via:
<script>
var auth2;
var SCOPE = ['https://www.googleapis.com/auth/adwords',
'https://www.googleapis.com/auth/yt-analytics.readonly',
'https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/yt-analytics-monetary.readonly',
'https://www.googleapis.com/auth/youtubepartner-channel-audit',
'https://www.googleapis.com/auth/youtubepartner',
'https://www.googleapis.com/auth/youtube.readonly',
] ;
function initClient() {
auth2 = gapi.auth2.init({
'clientId': 'my-client-id',
'scope': SCOPE.join(' '),
'prompt': 'consent',
})
}
function handleClientLoad() {
gapi.load('auth2', initClient);
}
</script>
<script async defer src="https://apis.google.com/js/api.js"
onload="this.onload=function(){};handleClientLoad()"
onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>
the access token I'm using is from the refresh token via:
https://www.googleapis.com/oauth2/v4/token?client_id={my_client_id}&client_secret={my_client_secret}&refresh_token={my_refresh_token}&grant_type=refresh_token
and I'm getting:
{
"access_token": "ya29.GlvyBZVPpC.....",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "https://www.googleapis.com/auth/youtubepartner https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/adwords https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/yt-analytics.readonly https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
"id_token": "eyJhbGciOiJSUz...."
}
I don't believe it's an issue with my scopes as I am not getting a 403 like:
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"errors": [
{
"message": "Request had insufficient authentication scopes.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}

Related

Getting access forbidden when calling a SendGrid API

Trying to invoke https://api.sendgrid.com/v3/suppression/bounces (https://docs.sendgrid.com/api-reference/bounces-api/retrieve-all-bounces) and I get a message of "access forbidden".
I am passing in a valid API Key, which is from a free new account.
API:
GET
Headers:
Authorization Bearer SG.xxxxxxxxxxxxxxxx
Accept application/json
Response:
{
"errors": [
{
"field": null,
"message": "access forbidden"
}
]
}

QuickBooksOnline API - Customer Balance API error - Permission Denied when other non reports API working

QuickBooksOnline API - Customer Balance is not working when other non reports API working with same access token
Request
https://sandbox-quickbooks.api.intuit.com/v3/company/123146076363264/reports/CustomerBalance?customer=1
Response
{
"Fault": {
"Error": [
{
"Message": "Permission Denied Error",
"Detail": "Permission Denied Error : You do not have the access rights to use this feature.",
"code": "5020",
"element": "ReportName"
}
],
"type": "ValidationFault"
},
"time": "2019-06-05T05:30:57.879-07:00"
}

When call google Execution API, Prompt "code": 401

Caught exception: {
"error": {
"code": 401,
"message": "ScriptError",
"errors": [
{
"message": "ScriptError",
"domain": "global",
"reason": "unauthorized"
}
],
"status": "UNAUTHENTICATED"
}
}
gs code:
function createForms() {
var form = FormApp.create('New Form');
Logger.log('Published URL: ');
}
If I remove var form = FormApp.create('New Form'), then it works

MS Graph Rest API Errors

I am getting the following errors for most of the resources in MS Graph.
Also the same resources are working fine with graph explorer ( https://graph.microsoft.io/en-us/graph-explorer ) using dummy tenant.
For POST /users
and PATCH /users
Status Code: 403
{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"request-id": "62c7e8f5-386a-4d15-8e94-5408d81b1383",
"date": "2017-01-24T09:08:46"
}
}
}
GET /drives
GET me/drive
Status Code: 500
{
"error": {
"code": "InternalServerError",
"message": "Unable to resolve template token",
"innerError": {
"request-id": "82ab9b86-7a90-4f86-877a-3ddb03ae1d71",
"date": "2017-01-24T09:12:35"
}
}
}
GET me/messages
GET me/events
GET me/mailFolders
GET me/contacts
Status Code: 504
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "678af389-cc38-4f5c-9b41-07595e62eee3",
"date": "2017-01-25T06:48:30"
}
}
}
Here is the list of scopes I have included.
"scope": "Calendars.Read Calendars.Read.Shared Calendars.ReadWrite Calendars.ReadWrite.Shared Contacts.Read Contacts.Read.Shared Contacts.ReadWrite Contacts.ReadWrite.Shared Directory.AccessAsUser.All Directory.Read.All Directory.ReadWrite.All email Files.Read Files.Read.All Files.Read.Selected Files.ReadWrite Files.ReadWrite.All Files.ReadWrite.AppFolder Files.ReadWrite.Selected Group.Read.All Group.ReadWrite.All IdentityRiskEvent.Read.All Mail.Read Mail.Read.Shared Mail.ReadWrite Mail.ReadWrite.Shared Mail.Send Mail.Send.Shared MailboxSettings.ReadWrite Notes.Create Notes.Read Notes.Read.All Notes.ReadWrite Notes.ReadWrite.All Notes.ReadWrite.CreatedByApp offline_access openid People.Read profile Sites.Read.All Tasks.Read Tasks.Read.Shared Tasks.ReadWrite Tasks.ReadWrite.Shared User.Read User.Read.All User.ReadBasic.All User.ReadWrite User.ReadWrite.All"

Download files from Google cloud storage

Can any one please tell me how to download or read the files from Google cloud storage without login/Authentication
when i tried the below link i am getting
https://www.googleapis.com/storage/v1/b/igvideos/o/test1235.txt
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Thanks
Thanigaivelan