YouTube Analytics API error - youtube

I am trying to get the same report that I see through their UI by using their API.
When I specify the following metrics and dimensions the query does not work:
Metrics - views, viewerPercentage, estimatedMinutesWatched, averageViewDuration, averageViewPercentage
Dimensions - insightTrafficSourceType
However, if I trim down the metrics to just: views, estimatedMinutesWatched the query works fine.
Here's the response I get in case of error from YouTube API:
HTTP/1.1 400 Bad Request
Vary: Origin
Vary: X-Origin
Content-Type: application/json; charset=UTF-8
Date: Wed, 06 Jan 2016 09:01:17 GMT
Expires: Wed, 06 Jan 2016 09:01:17 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic,p=1
Alt-Svc: quic=":443"; ma=604800; v="30,29,28,27,26,25"
Content-Length: 461
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v1/available_reports for a list of supported queries."
}
],
"code": 400,
"message": "The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v1/available_reports for a list of supported queries."
}
}

I've seen this error before when an invalid filter or dimension was used. I was able to duplicate this issue with the Google API Explorer and the issue went away when I removed the 'viewerPercentage' metric. This is strange since it is shown in YouTube documentation as a supported core metric: https://developers.google.com/youtube/analytics/v1/dimsmets/mets#viewerPercentage. I wasn't able to find anything in regards to it being deprecated, so I'm unsure as to the cause beyond it appearing to be a problem with the Youtube Analytics API.

Related

GET filesFolder API issue

We have a new problem when run this request: https://learn.microsoft.com/en-us/graph/api/channel-get-filesfolder?view=graph-rest-1.0&tabs=http
That is, GET /teams/{id}/channels/{id}/filesFolder
Previously, if a Team Channel was created via the API, it wasn't linked to a folder with files, until a user clicks Files in a Teams client and thus initializes it. And until it was initialized, the request would return Not Found 404.
However, since around February 25, 2021, in case the authenication uses MFA, we now get this error: Value cannot be null. Parameter name: token. But, the Authorization Token is present in the request as we verified with a traffic capture. Once you initialize the folder by clicking Files, the request starts to return valid data.
Is this a bug? Thanks.
GET https://graph.microsoft.com/v1.0/teams/.../channels/.../filesFolder?$select=id,name,webUrl,parentReference HTTP/1.1
Content-Type: application/json
User-Agent: <...>
Authorization: Bearer ...
Host: graph.microsoft.com
Connection: Keep-Alive
HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: application/json
request-id: ...
client-request-id: ...
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceC","Ring":"5","ScaleUnit":"005","RoleInstance":"AGSFE_IN_67"}}
Strict-Transport-Security: max-age=31536000
Date: Mon, 01 Mar 2021 19:38:40 GMT
Content-Length: 310
{
"error": {
"code": "BadRequest",
"message": "Value cannot be null.\r\nParameter name: token",
"innerError": {
"date": "2021-03-01T19:38:41",
"request-id": "...",
"client-request-id": "..."
}
}
}
We have Raised a Bug. We don't have ETA to share when it will be available.

Microsoft Graph API return ErrorInvalidMailboxItemId error

I use the Microsoft Graph API to crawl emails in Exchange Online.
If you try to crawl the ArchiveMsgFolderRoot folder using this API, you will get a ErrorInvalidMailboxItemId error.
GET https://graph.microsoft.com/v1.0/users/user_id/mailFolders/ArchiveRoot/
HTTP/1.1 404 Not Found
Cache-Control: private
Content-Type: application/json
request-id: ce60b00e-1703-450e-b8d2-0e8629519985
client-request-id: ce60b00e-1703-450e-b8d2-0e8629519985
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Japan East","Slice":"SliceC","Ring":"2","ScaleUnit":"000","RoleInstance":"AGSFE_IN_5"}}
Strict-Transport-Security: max-age=31536000
Date: Mon, 18 May 2020 06:40:06 GMT
Connection: close
Content-Length: 257
{
"error": {
"code": "ErrorInvalidMailboxItemId",
"message": "Item Id doesn't belong to the current mailbox.",
"innerError": {
"request-id": "ce60b00e-1703-450e-b8d2-0e8629519985",
"date": "2020-05-18T06:40:07"
}
}
}
The error did not return at least around March.
The same applies to the following folders.
https://graph.microsoft.com/v1.0/users/user_id/mailFolders/ArchiveMsgFolderRoot/
https://graph.microsoft.com/v1.0/users/user_id/mailFolders/ArchiveDeletedItems/
Has the Microsoft Graph folder naming scheme changed?
This is not possible: The API does not support accessing in-place archive mailboxes, not on Exchange Online nor on Exchange Server.
That's why neither ArchiveMsgFolderRoot nor ArchiveDeletedItems is not listed under the Well-known folder names.
Finally, Cross-mailbox API calls will fail starting April 15, 2020.

Unable to get access token after updating redirect list in google console. "error_description": "Unauthorized", "error": "unauthorized_client"

I'm trying to get refresh token which doesn't expire after 24 hours on google oauthplayground but Im getting error as :
{
"error_description": "Unauthorized",
"error": "unauthorized_client"
}
I updated my redirect url in google console with https://developers.google.com/oauthplayground.
I also updated my client id and client secret in configuration setting on google oauth playground.
Some posts mentioned that it would take some time but I had done this 12 hours ago but still getting the error.
Any help would be much appreciated.
Below is complete response :
HTTP/1.1 400 Bad Request
Content-length: 68
X-xss-protection: 0
X-content-type-options: nosniff
Transfer-encoding: chunked
Vary: Origin, X-Origin, Referer
Server: scaffolding on HTTPServer2
-content-encoding: gzip
Cache-control: private
Date: Sun, 14 Jul 2019 11:35:13 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="46,43,39"
Content-type: application/json; charset=utf-8
{
"error_description": "Bad Request",
"error": "invalid_grant"
}
unauthorized_client
Means that the Client id and or secret you are sending either is invalid (its been deleted) or you copied it wrong from the Google developer console.
Unless you only attend to ever have one user and refresh token for your application you really shouldn't be using developer console to generate tokens. You should do this with your own application.

How to check GoogleSignIn User has uploaded image or default image set by Google

Google User getting below type default image when user does not have uploaded his image.
GIDGoogleUser has GIDProfileData object which has "hasImage" boolean variable. It is always returns true.
Is there is any way we are able to know User has uploaded his profile picture or it is default set by Google through "GoogleSignIn" components.
When you do a signin with google assuming that you requested one of the profile scopes (i think) You can make a request against the userinfo endpoint
GET /oauth2/v2/userinfo HTTP/1.1
Host: www.googleapis.com
Content-length: 0
Authorization: Bearer ya29.GltcBnVqN8CQ5VpTe0qVSwYomBDGkAGtUSzvYBGti_mFKfemFjIPOE00HCOkfqMXpKVS6qUeMKgnzj2uPrxgvmBeeX4b0pDur3ttfGANCWceotLBMqFO4I47b9
This will return the public profile information that google has on the User.
HTTP/1.1 200 OK
Content-length: 313
X-xss-protection: 1; mode=block
Content-location: https://www.googleapis.com/oauth2/v2/userinfo
X-content-type-options: nosniff
Transfer-encoding: chunked
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Vary: Origin, X-Origin, Referer
Server: ESF
-content-encoding: gzip
Pragma: no-cache
Cache-control: no-cache, no-store, max-age=0, must-revalidate
Date: Thu, 22 Nov 2018 07:06:47 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="44,43,39,35"
Content-type: application/json; charset=UTF-8
{
"picture": "https://lh5.googleusercontent.com/-a1CWlFnA5xE/AAAAAAAAAAI/AAAAAAAAl1I/UcwPajZOuN4/photo.jpg",
"name": "Linda Lawton",
"family_name": "Lawton",
"locale": "en",
"gender": "female",
"link": "https://plus.google.com/+LindaLawton",
"given_name": "Linda",
"id": "117200475532672775346"
}
As you can see it is returning my picture. This is the picture that i beleave i have uploaded to my Google+ account. As google is discontinuing Google+ i suspect these have all been exported over to the users Google account and there must be a way to upload a picture from their.
Now If I make a request against an account where i have not uploaded an image I get
HTTP/1.1 200 OK
Content-length: 326
X-xss-protection: 1; mode=block
Content-location: https://www.googleapis.com/oauth2/v2/userinfo
X-content-type-options: nosniff
Transfer-encoding: chunked
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Vary: Origin, X-Origin, Referer
Server: ESF
-content-encoding: gzip
Pragma: no-cache
Cache-control: no-cache, no-store, max-age=0, must-revalidate
Date: Thu, 22 Nov 2018 07:11:24 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="44,43,39,35"
Content-type: application/json; charset=UTF-8
{
"picture": "https://lh5.googleusercontent.com/-GTTySn-WtmA/AAAAAAAAAAI/AAAAAAAAAAA/AGDgw-imFDZsZC-MaGnPIHPnh2Z95O-cSA/mo/photo.jpg",
"name": "Linda Lawton",
"family_name": "Lawton",
"locale": "da",
"link": "https://plus.google.com/108097091072786400385",
"given_name": "Linda",
"id": "108097091072786400385"
}
Which is
So even if the user has not personally uploaded an image Google creates a dummy one for them out of the first letter of their first or last name. There is no way for you to know if its a dummy image or an actual image unless you create some kind of image recognition system for detecting the dummy images.
Note: All of this was tested using oauthplayground data will be the same in IOs responses as well.
If he have not selected an image from withing your application. And there is an image that is being uploaded, then high chances are that it is an image provided by google. Just make sure to exempt place holder image when you are trying to upload.
As for checking if google returned image is a image that user uploaded or google default, I checked with different path for both type of image and see no identifier that can segregate 2 type of images.
As google is providing default profile pictures with the first letter of name it is quite difficult to identify if the profile picture is set by the user on google account or not. But if you want this any how then you can user OCR to identify if there is only one alphabet in the image retrieved from the google and that is same as the first letter of the Name of the user. Refer this link for OCR.
SwiftOCR
Thanks

Youtube API v3 video.update response 400 - invalidRequest

the problem is fairly simple, I cannot make a very simple request to youtube api video.update without getting a 400 response with a reason 'invalidRequest'. I'am using Youtube API Explorer (https://developers.google.com/youtube/v3/docs/videos/update). The account is authorized. Other API methods such as playlists.update and videos.list works just fine. Please help with this video.update request.
Test request sent:
PUT https://www.googleapis.com/youtube/v3/videos?part=snippet&key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer {AUTH_KEY}
X-JavaScript-User-Agent: Google APIs Explorer
{
"id": "{VIDEO_ID}",
"snippet": {
"title": "title change to test1",
"description": "description change to test"
}
}
Response received:
400 Bad Request
- Hide headers -
cache-control: private, max-age=0
content-encoding: gzip
content-length: 134
content-type: application/json; charset=UTF-8
date: Sun, 26 Jan 2014 18:48:13 GMT
expires: Sun, 26 Jan 2014 18:48:13 GMT
server: GSE
{
"error": {
"errors": [
{
"domain": "youtube.video",
"reason": "invalidRequest",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
Seems like snippet.categoryId property is required and it is not documented that you must specify it. Adding this property to a request body solved the problem.

Resources