java - token 无效 - 无效 token : Cannot parse referred token string: Invalid gaia_data. Base64 token 上的 AuthSubToken 原型(prototype)

标签 java google-sheets google-api gmail-api google-sheets-api

我通过 Java 应用程序使用 Google 电子表格时遇到了问题。 我创建了应用程序,该应用程序运行了 1 年多,没有任何问题,我什至在 Create Spreadsheet using Google Spreadsheet API in Google drive in Java 下发布了 Google API 更改的解决方案 昨天我不知道为什么,但它停止工作,现在我只有一个异常(exception):

Exception in thread "main" com.google.gdata.client.GoogleService$SessionExpiredException: Token invalid - Invalid token: Cannot parse referred token string: Invalid gaia_data.AuthSubToken proto on base64 token.

token 无效 - 无效 token :无法解析引用的 token 字符串:base64 token 上的 gaia_data.AuthSubToken 原型(prototype)无效。 token 无效 - 无效 token :无法解析引用的 token 字符串:base64 token 上的 gaia_data.AuthSubToken 原型(prototype)无效。 错误401

at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:570)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
at com.google.gdata.client.Service.getFeed(Service.java:998)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:645)
at com.google.gdata.client.Service.getFeed(Service.java:1017)
at SandboxAll.<init>(SandboxAll.java:155)
at SandboxCheck.main(SandboxCheck.java:207)

这是代码的一部分,以前工作正常,但现在不行了:

SpreadsheetService service;
SpreadsheetFeed feed;   
SPREADSHEET_FEED_URL = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full");
        com.google.api.client.json.jackson.JacksonFactory jsonFactory = new com.google.api.client.json.jackson.JacksonFactory();
        String[] SCOPESArray = {"https://spreadsheets.google.com/feeds", "https://spreadsheets.google.com/feeds/spreadsheets/private/full", "https://docs.google.com/feeds"};
        final List SCOPES = Arrays.asList(SCOPESArray);
        GoogleCredential credential = new GoogleCredential.Builder()
                .setTransport(httpTransport)
                .setJsonFactory(jsonFactory)
                .setServiceAccountId("xxxxxx@developer.gserviceaccount.com")
                .setServiceAccountScopes(SCOPES)
                .setServiceAccountPrivateKeyFromP12File(p12)
                .build();
        service = new SpreadsheetService("Sandbox");
        service.setOAuth2Credentials(credential);
        service.setReadTimeout(160000);
        service.setConnectTimeout(16000);
        --->feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class); <---

异常在 feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class); 我一直在互联网上寻找任何答案,但现在可以找到任何答案。 谷歌又改变了什么吗? 我已经重新创建了我的帐户,但这没有帮助。

最佳答案

(我不想编辑我的答案,因此任何有相同问题的人都可以尝试检查与我相同的解决方案) 我不知道,但就我而言,仅为 feed 设置范围

 String[] SCOPESArray = {"https://spreadsheets.google.com/feeds"/*, "https://spreadsheets.google.com/feeds/spreadsheets/private/full", "https://docs.google.com/feeds","https://www.googleapis.com/auth/drive"*/};

有帮助。当我显示refreshToken()时

System.out.println(credential.refreshToken());

我注意到一些提要具有错误的值(value)。

关于java - token 无效 - 无效 token : Cannot parse referred token string: Invalid gaia_data. Base64 token 上的 AuthSubToken 原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40278900/

相关文章:

python - 通过 Google Sheets API 和 Python 阅读 Sheet 2

java - 为什么Spring MVC会以404响应并报告“在DispatcherServlet中未找到带有URI […]的HTTP请求的映射”?

java - ViewPager 致命异常 : main

java - 休息服务: how to produce human readable output using XML + XSLT?

java - 为什么 SpringSecurity 在注销后继续提供相同的经过身份验证的主体

javascript - 如何将参数传递给 Google Apps 脚本调试器?

google-apps-script - 根据值更改编辑单元格背景颜色

javascript - 比较 JavaScript 中的两个日期(字符串)不起作用

javascript - 在 Google Calendar API 中获取用户个人资料名称和图像

java - 401 错误未知授权检索谷歌日历