Youtube v3 api says "exceeded quota" but my usage is 0 - youtube-api

this a message for Google Support! My API key and request to Youtube API is saying I have exceeded my quota, but I have not used the API and my Quota page shows no usage.
When I make a simple list request (one of perhaps 10 because my app is in development) I receive the following error :
array:1 [
"error" => array:3 [
"code" => 403
"message" => "The request cannot be completed because you have exceeded your quota."
"errors" => array:1 [
0 => array:3 [
"message" => "The request cannot be completed because you have exceeded your quota."
"domain" => "youtube.quota"
"reason" => "quotaExceeded"
]
]
this is after creating a brand new API key for my application. How can my quota be exceeded when I haven't used it?

Related

Randomly started to get 400 "Invalid request" error: "The provided encoding is not supported."

Starting around 00:10 UTC on Saturday 30th Jan 2021 we've started to see some of our cron jobs that update Microsoft shared calendar entries randomly return a 400 with the following error in the returned JSON contents:
'{ "error": { "code": "invalidRequest", "message": "The provided encoding is not supported." } }',
These appear randomly - if I rerun the command that created it there a good chance it will work just fine. Our cron job runs every hour (it's maintaining a share calendar of approved changes from our change management system) and the events it fails on appear to be different on every run.
Has something changed with Graph API over the weekend or are Microsoft's server experiencing heavy load? This seems like a really weird error message to get from an overloaded service though - I've gone down the rabbit hole of trying to work out what encoding it's talking about without any luck (especially as debugging is tricky because re-running calendar entry scripts by hand often works!). Searching for 'Microsoft Graph API "The provided encoding is not supported"' hasn't really thrown much up either so I'm a bit stumped now. Ideas anyone?
EDIT: The request is being made from a Perl script using LWP to PATCH to the https://graph.microsoft.com/v1.0/users/<user-id>/calendars/<calendar-id>. Here's an example of the dump of the object structure when we get the error (with the bearer key deleted obviously!). This contains everything being sent and everything being returned:
[69295] [Mon Feb 1 08:10:07 2021] [warning]: Event creation failed. LWP UA response object:
$VAR1 = bless( {
'_protocol' => 'HTTP/1.1',
'_content' => '{ "error": { "code": "invalidRequest", "message": "The provided encoding is not supported." } }',
'_rc' => 400,
'_headers' => bless( {
'connection' => 'close',
'client-response-num' => 1,
'date' => 'Mon, 01 Feb 2021 08:10:07 GMT',
'client-ssl-cert-issuer' => '/C=US/O=Microsoft Corporation/CN=Microsoft Azure TLS Issuing CA 01',
'client-ssl-cipher' => 'ECDHE-RSA-AES128-GCM-SHA256',
'client-peer' => '20.190.169.24:443',
'strict-transport-security' => 'max-age=31536000',
'content-length' => '95',
'::std_case' => {
'client-response-num' => 'Client-Response-Num',
'client-ssl-cert-issuer' => 'Client-SSL-Cert-Issuer',
'client-ssl-cipher' => 'Client-SSL-Cipher',
'client-peer' => 'Client-Peer',
'strict-transport-security' => 'Strict-Transport-Security',
'client-date' => 'Client-Date',
'client-ssl-cert-subject' => 'Client-SSL-Cert-Subject',
'client-ssl-socket-class' => 'Client-SSL-Socket-Class'
},
'client-date' => 'Mon, 01 Feb 2021 08:10:07 GMT',
'content-type' => 'application/json',
'client-ssl-cert-subject' => '/C=US/ST=WA/L=Redmond/O=Microsoft Corporation/CN=graph.microsoft.com',
'client-ssl-socket-class' => 'IO::Socket::SSL'
}, 'HTTP::Headers' ),
'_msg' => 'Bad Request',
'_request' => bless( {
'_content' => '{"extensions":[{"#odata.type":"Microsoft.Graph.OpenTypeExtension","RTTicketId":"236595","extensionName":"uk.ac.lboro.lunet.RTTicketId"}],"body":{"content":"<a href=\'https://servicedesk.lboro.ac.uk/Changes/Normal.html?id=236595\'>Change details in RT</a>.<br><br><h2>Test</h2><h3>Risk Level: Low</h3>","contentType":"HTML"},"singleValueExtendedProperties":[{"value":"236595","id":"String {E6F70170-9BED-11E8-8CBC-CDC132C02D95} Name RTTicketId"}],"subject":"RT Ticket# 236595 Test (Drafting (draft))","showAs":"tentative","end":{"timeZone":"UTC","dateTime":"2021-01-29 17:00:00"},"start":{"timeZone":"UTC","dateTime":"2021-01-29 07:00:00"}}',
'_uri' => bless( do{\(my $o = 'https://graph.microsoft.com/v1.0/users/8c0729fb-fdd8-4c47-afdd-6319d7f53527/calendars/AAMkADcyNzFmM2NmLTQwNWUtNDdkYi05NjBkLTMyY2Y0YWZmNjNjOABGAAAAAADLxa7s4pdTQYKigJvn9tIVBwCQ07ZtjCb-RJqL4KgdwIpWAAAA2V50AABdqLP0L9GOTKSkX7kyfyLXACFn_IIFAAA=/events/AAMkADcyNzFmM2NmLTQwNWUtNDdkYi05NjBkLTMyY2Y0YWZmNjNjOABGAAAAAADLxa7s4pdTQYKigJvn9tIVBwCQ07ZtjCb-RJqL4KgdwIpWAAAA2V53AACCh71i_SZfT6deBOa2tmDIAAW36HLpAAA=')}, 'URI::https' ),
'_headers' => bless( {
'user-agent' => 'libwww-perl/6.49',
'content-type' => 'application/json; charset=utf8',
'::std_case' => {
'if-ssl-cert-subject' => 'If-SSL-Cert-Subject'
},
'authorization' => 'Bearer <deleted>'
}, 'HTTP::Headers' ),
'_method' => 'PATCH',
'_uri_canonical' => $VAR1->{'_request'}{'_uri'}
}, 'HTTP::Request' )
},
I was facing the same issue, but executed a totally different Graph call: My call creates a Microsoft Team and has been successfully working for years... For the last few days, it randomly fails with the same error Jon mentioned.
I made sure that the JSON which is sent as the Payload of the Graph request always gets serialized as UTF-8 encoded string... Even that I cannot be sure that this fixed the issue, I didn't observe errors since then...

How to fix the 'invalid_grant' error when using Google Photos API

I'm trying to use the Google Photos API (quite a newbie on this). I've managed to go through the authentication/consent process. I stored the authorization code that was returned by Google. On a later moment, I'm trying to use this authorization code to use the Google Photos API. Below a code snippet.
// $clientId and $clientSecret are read from my .json file
// $state was randomly generated, used in the registration process and stored to/read from the database
// $code was stored to the database at the end of te registration process and read from the database to pass in subjoined call
// $redirectUrl and $scope are hard coded for now
$oauth = new OAuth2( [
'clientId' => $clientId,
'clientSecret' => $clientSecret,
'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth',
'state' => $state,
'redirectUri' => $redirectUrl,
'tokenCredentialUri' => 'https://www.googleapis.com/oauth2/v4/token',
'scope' => $scope,
] );
$oauth->setCode( $code );
$credentials = new UserRefreshCredentials(
$this->getScope(),
[
'client_id' => $oauth->getClientId(),
'client_secret' => $oauth->getClientSecret(),
'refresh_token' => $oauth->getRefreshToken()
]
);
$client = new PhotosLibraryClient( [ 'credentials' => $credentials ] );
For the refresh_token, I've tried both $oauth->fetchToken()['access_token'] as well as $oauth->getRefreshToken().
Unfortunately, I get an exception:
guzzlehttp/guzzle/src/Exception/RequestException.php # 113 : Client error: `POST https://www.googleapis.com/oauth2/v4/token` resulted in a `400 Bad Request` response: { "error": "invalid_grant", "error_description": "Bad Request" }
Anyone any idea what could be wrong here?

Authorization Required on Twitter Stream Api using Guzzle PHP

I want to use the Twitter Streaming Api with the filter query.
And following the GuzzleHttp documentation I'm accessing like this:
<?php
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Subscriber\Oauth\Oauth1;
$stack = HandlerStack::create();
$middleware = new Oauth1([
'consumer_key' => 'my_key',
'consumer_secret' => 'my_secret',
'token' => 'my_token',
'token_secret' => 'my_token_secret'
]);
$stack->push($middleware);
$client = new Client([
'base_uri' => 'https://stream.twitter.com/1.1/',
'handler' => $stack,
'auth' => 'oauth'
]);
$client->post('statuses/filter.json', [
'form_params' => [
'track' => 'some_word_to_track',
],
]);
But when executing this code, I'm getting the following exception:
PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException:
Client error: 'POST https://stream.twitter.com/statuses/filter.json'
resulted in a '401 Authorization Required' response
in /Users/.../vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111
Conclusion:
Is it because I cannot use GuzzleHttp's Oauth1 Subscriber with
Twitter streaming API?
Or is it because I missing something on the
authentication?

Google_AuthException [ 400 ]: Error fetching OAuth2 access token, message: 'invalid_grant'

The problem arises when I get the code and makes a request for a token. For authorization using code that works fine on other projects. I check Credentials in developer console and my config file. Attempts to connect the authorization from other sites and other accounts yielded nothing. I checked redirects, headers, but found nothing.
$request = Google_Client::$io->makeRequest(new Google_HttpRequest('https://accounts.google.com/o/oauth2/token', 'POST', array(), array(
'code' => $_GET['code'],
'grant_type' => 'authorization_code',
'redirect_uri' => $this->redirectUri,
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret
)));
This request return "Error fetching OAuth2 access token, message: 'invalid_grant'"

Google Reseller API returning "Resource already exists" on Insert Customer

Dear Google Engineers,
I keep trying to insert a customer and receive the following response:
[error] => Array
(
[errors] => Array
(
[0] => Array
(
[domain] => global
[reason] => duplicate
[message] => Resource already exists
)
)
[code] => 409
[message] => Resource already exists
)
I then go about attempting to retrieve the customer resource that supposedly exists via a GET request to https://www.googleapis.com/apps/reseller/v1/customers/{customerId} which fails to find the resource:
[error] => Array
(
[errors] => Array
(
[0] => Array
(
[domain] => global
[reason] => notFound
[message] => Not Found
)
)
[code] => 404
[message] => Not Found
)
Either I've uncovered a bug or the error response from POST https://www.googleapis.com/apps/reseller/v1/customers/ isn't nearly detailed enough for me to diagnose.
I've tried variations of the required fields with random values (addressLine1, alternateEmail, phoneNumber). I've also logged in to the Reseller CPanel and no matching customer exists for the domain.
If Google engineers care to try and diagnose internally, the customerId in question is ruby-stagingpop.co. You can email me to find out my Reseller account if necessary. Info in my profile.

Resources