Reputation: 13
I'm creating YouTube's metrics monitoring feature. But I faced one confusing point while using YouTube Data API.
I want to retrieve all video IDs of one YouTube channel. I'm using Lambda for this process.
Before API call, I'm refreshing the access token every time within the Lambda.
In order to retrieve video IDs, I used search#list
with the following parameters:
part
: "id"
forMine
: true
type
: "video"
maxResults
: 50
Then, we can get the result like the following:
{
"kind": "youtube#searchListResponse",
"etag": "7d3zMRNK3SwAAdU_zX5Yo9oMezw",
"nextPageToken": "SampleNextPageTokenParamXXX",
"pageInfo": {
"totalResults": 54,
"resultsPerPage": 50
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "etag1",
"id": {
"kind": "youtube#video",
"videoId": "sampleVideoId1"
}
},
{
"kind": "youtube#searchResult",
"etag": "etag2",
"id": {
"kind": "youtube#video",
"videoId": "sampleVideoId2"
}
},
...
}
Next, I tried to call the API with the following.
part
: "id"
forMine
: true
type
: "video"
maxResults
: 50
pageToken
: "SampleNextPageTokenParamXXX"
(added)Then, we had two situations.
{
"error": {
"code": 400,
"message": "Therequestspecifiesaninvalidpagetoken.",
"errors": [
{
"message": "The request specifies an invalid page token.",
"domain": "youtube.parameter",
"reason": "invalidPageToken",
"location": "pageToken",
"locationType": "parameter"
}
]
}
}
I'm thinking this trouble happened from the access token's management solution, and this happened when the access token was inactivated by other processes working in parallel or Lambda's auto retrying process. But if you have any solution other than the viewpoint of tokens, could you tell us? Best Regards.
Upvotes: 1
Views: 90
Reputation: 38
It seems there was a transient (known within Google) issue, where the nextPageToken
was not working properly.
Google's staff reported that it was fixed: '400 invalidPageToken' error returned for a valid Next Page Token
Upvotes: 1