NextPageToken给出无效的输入错误400-Google Directory API ChomeDevices [英] NextPageToken gives invalid input error, 400 - Google Directory API ChomeDevices

查看:64
本文介绍了NextPageToken给出无效的输入错误400-Google Directory API ChomeDevices的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从Google工作区(Gsuite)中提取25万本Chromebook,我正在使用Admin Directory API从Google检索JSON数据.

I have to fetch 250K chromebooks from google workspace (Gsuite), I am using Admin Directory API to retrieve JSON data from Google.

响应以200条记录的块返回,响应中包含一个 nextPageToken ,我使用该下一页标记来检索下200条,依此类推.

The response returns in chunks of 200 records, in the response is included a nextPageToken, I use that next page token to retrieve the next 200 and so on.

一个小时后,使用上一个请求附带的 nextPageToken ,但是Google返回错误400,

After an hour, of using the nextPageToken attached from the previous request, However Google returns with error 400,

{错误代码:400,消息" =>无效的输入:CMiJhq7-5ewCEp0BCm737N8GN ......"},

{error_code: 400, "message"=>"Invalid Input: CMiJhq7-5ewCEp0BCm737N8GN......"},

注意:谷歌称其为无效字符串"CMiJhq7-5ewCEp0BCm737N8GN ......"是nextPageToken.

Note: This string 'CMiJhq7-5ewCEp0BCm737N8GN......' which google is calling as invalid is the nextPageToken.

为什么会这样?nextPageToken会在1小时后过期吗?

Why is this happening? Does nextPageToken expire after 1 hour?

我的代码段:

query_list = {
      'maxResults' => 200,
      'access_token' => access_token,
      'pageToken' => next_page_token
    }
HTTParty.get(endpoint_url, query: query_list)

推荐答案

发送初始请求时,将创建nextPage令牌.使用此令牌是为了从请求中获取下一批行.

The nextPage token is created when the initial request is sent. This token is used in order to get the next batch of rows from the request.

此令牌旨在立即使用,因为如果您等待很长时间,与初始请求关联的数据可能会更改.

This token is intended to be used immediately as the data associated with the initial request may be changed if you wait to long.

是的,下一页令牌确实会过期,我实际上希望它们在不到一个小时的时间内过期.我还想知道,下一页令牌在您第一次使用后是否还会过期吗?

So yes next page tokens do expire i would actually expect them to expire in a lot less than an hour. I also wonder if the next page token wouldn't just expire after you used it the first time.

如果您想再次发出相同的请求,我建议您这样做,并在小时后为您建立新的下一页令牌.

If you want to make the same request again i suggest you do that and get new next page tokens built for you after the hour.

这篇关于NextPageToken给出无效的输入错误400-Google Directory API ChomeDevices的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆