令牌无效 - 令牌无效:无法解析引用的令牌字符串:base64令牌上的无效gaia_data.AuthSubToken原型 [英] Token invalid - Invalid token: Cannot parse referred token string: Invalid gaia_data.AuthSubToken proto on base64 token
问题描述
我通过Java应用程序处理谷歌电子表格的问题。
我创建了应用程序,在超过1年的时间内没有任何问题,我甚至在在Google驱动器中使用Google电子表格API创建Spreadsheet API
昨天我不知道为什么,但它停止工作,现在我只有一个例外:
线程main中的异常com.google.gdata.client.GoogleService $ SessionExpiredException:令牌无效 - 令牌无效:无法解析引用的令牌字符串:base64令牌上的无效gaia_data.AuthSubToken proto。
令牌无效 - 无效令牌:无法解析引用的令牌字符串:base64令牌上的无效gaia_data.AuthSubToken原型。
令牌无效 - 无效令牌:无法解析引用的令牌字符串:base64令牌上的无效gaia_data.AuthSubToken proto。
错误401
at 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 )
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)
SandboxAll。< init>(SandboxAll.java:155)
SandboxCheck.main(SandboxCheck.java:207 )
这是可以正常工作的代码的一部分,现在不是:
SpreadsheetService服务;
SpreadsheetFeed供稿;
SPREADSHEET_FEED_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 /馈送};
final List SCOPES = Arrays.asList(SCOPESArray);
GoogleCredential凭证=新的GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(xxxxxx@developer.gserviceaccount.com)
.setServiceAccountScopes(SCOPES)
.setServiceAccountPrivateKeyFromP12File(p12)
.build();
service = new SpreadsheetService(Sandbox);
service.setOAuth2Credentials(凭证);
service.setReadTimeout(160000);
service.setConnectTimeout(16000);
---> feed = service.getFeed(SPREADSHEET_FEED_URL,SpreadsheetFeed.class); < ---
异常是抛出 feed = service.getFeed (SPREADSHEET_FEED_URL,SpreadsheetFeed.class);
我在网上寻找任何答案,但现在可以找到anythig。
谷歌又改变了一些东西?
我已经重新创建了我的帐户,但这并没有帮助。
(我不想编辑我的答案,以便任何人有同样的问题将能够尝试检查相同的解决方案,因为我)
我不知道,但在我的情况设置范围只为饲料
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()时,我们可以使用这个方法来创建一个新的表单。
我注意到一些提要有错误的值。
I've strage issue with google spreadsheet via Java application. I had application created which was working without any issue for more than 1 year I even posted an solution for Google API change under Create Spreadsheet using Google Spreadsheet API in Google drive in Java Yesterday I don't know why but it stopped working and now I've only 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 invalid - Invalid token: Cannot parse referred token string: Invalid gaia_data.AuthSubToken proto on base64 token. Token invalid - Invalid token: Cannot parse referred token string: Invalid gaia_data.AuthSubToken proto on base64 token. Error 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)
This is part of the code which was working fine and now it's not:
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); <---
The exception is throw on feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class);
I was looking for any answer in the internet but could now find anythig.
Did google again changed something ?
I've recreate my account this this did not help.
(I don't want to edit my answer so anyone with the same issue will be able to try to check the same solution as I did) I don't know but in my case setting Scope only for 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"*/};
helped. When I was displaying refreshToken()
System.out.println(credential.refreshToken());
I've notice that some of the feeds had false value.
这篇关于令牌无效 - 令牌无效:无法解析引用的令牌字符串:base64令牌上的无效gaia_data.AuthSubToken原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!