Java 令牌无效-无效令牌:无法分析引用的令牌字符串:base64令牌上的gaia_data.AuthSubToken proto无效
我通过Java应用程序解决了谷歌电子表格的问题。 我创建的应用程序在一年多的时间里没有任何问题,我甚至发布了一个谷歌API变更的解决方案 昨天我不知道为什么,但它停止了工作,现在我只有一个例外:Java 令牌无效-无效令牌:无法分析引用的令牌字符串:base64令牌上的gaia_data.AuthSubToken proto无效,java,google-sheets,google-api,gmail-api,google-spreadsheet-api,Java,Google Sheets,Google Api,Gmail Api,Google Spreadsheet Api,我通过Java应用程序解决了谷歌电子表格的问题。 我创建的应用程序在一年多的时间里没有任何问题,我甚至发布了一个谷歌API变更的解决方案 昨天我不知道为什么,但它停止了工作,现在我只有一个例外: Exception in thread "main" com.google.gdata.client.GoogleService$SessionExpiredException: Token invalid - Invalid token: Cannot parse referred token str
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.
令牌无效-无效令牌:无法分析引用的令牌字符串:base64令牌上的gaia_data.AuthSubToken proto无效。
令牌无效-无效令牌:无法分析引用的令牌字符串:base64令牌上的gaia_data.AuthSubToken proto无效。
错误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)
com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:570)
位于com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
位于com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
位于com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
位于com.google.gdata.client.Service.getFeed(Service.java:1135)
位于com.google.gdata.client.Service.getFeed(Service.java:998)
位于com.google.gdata.client.GoogleService.getFeed(GoogleService.java:645)
位于com.google.gdata.client.Service.getFeed(Service.java:1017)
在Sandboxal。(sandboxal.java:155)
位于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); <---
电子表格服务;
电子表格;
电子表格\u提要\u URL=新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();
字符串[]范围数组={”https://spreadsheets.google.com/feeds", "https://spreadsheets.google.com/feeds/spreadsheets/private/full", "https://docs.google.com/feeds"};
最终列表SCOPES=Arrays.asList(SCOPESArray);
GoogleCredential credential=新建GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.SetServiceAccounted(“xxxxxx@developer.gserviceaccount.com")
.setServiceAccountScopes(范围)
.SetServiceAccountPrivateKeyfromP12文件(p12)
.build();
服务=新的电子表格服务(“沙箱”);
服务。设置OAuth2Credentials(凭证);
服务设置读取超时(160000);
设置连接超时(16000);
--->feed=service.getFeed(电子表格\u feed\u URL,SpreadsheetFeed.class) (我不想编辑我的答案,因此任何有相同问题的人都可以尝试检查与我相同的解决方案)
我不知道,但在我的例子中,设置范围仅限于提要
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());