令牌无效 - 无效令牌:无法解析引用的令牌字符串:base64令牌上无效的gaia_data.AuthSubToken原型

时间:2016-10-27 07:40:07

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

我通过Java应用程序使用Google电子表格存在问题。 我创建的应用程序在没有任何问题的情况下工作超过1年我甚至在Create Spreadsheet using Google Spreadsheet API in Google drive in Java下发布了针对Google API更改的解决方案 昨天我不知道为什么但它停止了工作,现在我只是例外:

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)

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

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); 我在互联网上寻找任何答案,但现在可以找到任何答案。 谷歌又改变了一些东西吗? 我重新创建了我的帐户,但这没有帮助。

1 个答案:

答案 0 :(得分:0)

(我不想编辑我的答案,所以任何有相同问题的人都可以尝试检查与我相同的解决方案) 我不知道,但在我的情况下,仅为Feed设置范围

namespace StokUygulamasi

[Database(Name = "HarleyDavidson")]

class HarleyDavidson : DataContext
{
    public HarleyDavidson() : base("Data Source=SELCUK-CODE\\LOCALHOST;Initial Catalog = HarleyDavidson; Integrated Security = true")
    {

    }
    public HarleyDavidson(SqlConnection con) : base(con) { }

    public Table<Motor> Motor
    {
        get
        {
            return this.GetTable<Motor>();
        }
    }

    public Table<IkinciEl> IkinciEl
    {
        get
        {
            return this.GetTable<IkinciEl>();
        }
    }

    public Table<Musteri> Musteri
    {
        get
        {
            return this.GetTable<Musteri>();
        }
    }

    public Table<Satis> Satis
    {
        get
        {
            return this.GetTable<Satis>();
        }
    }
}

[Table(Name = "Motor")]
public class Motor
{
    [Column(Storage = "MotorID", DbType ="Int Not null", IsPrimaryKey = true, IsDbGenerated = true)]
    public int MotorID;
    [Column(Storage = "Marka", DbType = "nvarchar(20) Not null")]
    public string Marka;
    [Column(Storage = "Model", DbType = "nvarchar(20) Not null")]
    public string Model;
    [Column(Storage = "Seri", DbType = "nvarchar(20) Not null")]
    public string Seri;
    [Column(Storage = "Plaka", DbType = "nvarchar(20) Not null")]
    public string Plaka;
    [Column(Storage = "Sasi", DbType = "char(17) Not null")]
    public string Sasi;
    [Column(Storage = "KM", DbType = "int Not null")]
    public int KM;
    [Column(Storage = "Yil", DbType = "int Not null")]
    public int Yil;
    [Column(Storage = "AlisFiyat", DbType = "decimal(18,2) Not null")]
    public decimal AlisFiyat;
    [Column(Storage = "SatisFiyat", DbType = "decimal(18,2) Not null")]
    public decimal SatisFiyat;
}
[Table(Name = "Musteri")]
public class Musteri
{
    [Column(Storage = "MusteriID", DbType = "Int Not null", IsPrimaryKey = true, IsDbGenerated = true)]
    public int MusteriID;
    [Column(Name = "Ad", DbType = "nvarchar(100) Not null")]
    public string Ad;
}

[Table(Name = "Satis")]
public class Satis
{
    [Column(Name = "SatisID", DbType = "Int Not null", IsPrimaryKey = true, IsDbGenerated = true)]
    public int SatisID;
    [Column(Name = "Tarih", DbType = "Date Not null")]
    public DateTime Tarih;
    [Column(Name = "Musteri", DbType = "nvarchar(100) Not null")]
    public string Musteri;
    [Column(Name = "Arac", DbType = "nvarchar(10) Not null")]
    public string Arac;
    [Column(Name = "AracSasi", DbType = "char(17) Not null")]
    public string AracSasi;
    [Column(Name = "Tutar", DbType = "decimal(18,2) Not null")]
    public decimal Tutar;



}

[Table(Name = "IkinciEl")]
public class IkinciEl
{
    [Column(Name = "IkinciElID", DbType = "int Not null", IsPrimaryKey = true, IsDbGenerated = true)]
    public int IkinciElID;
    [Column(Name = "Marka", DbType = "nvarchar(20) Not null")]
    public string Marka;
    [Column(Name = "Model", DbType = "nvarchar(20) Not null")]
    public string Model;
    [Column(Name = "Seri", DbType = "nvarchar(20) Not null")]
    public string Seri;
    [Column(Name = "Plaka", DbType = "nvarchar(10) Not null")]
    public string Plaka;
    [Column(Name = "Sasi", DbType = "char(17) Not null")]
    public string Sasi;
    [Column(Name = "KM", DbType = "int Not null")]
    public int KM;
    [Column(Name = "Yil", DbType = "int Not null")]
    public int Yil;
    [Column(Name = "Fiyat", DbType = "decimal(18,2) Not null")]
    public decimal Fiyat;
}

private void Form1_Load(object sender, EventArgs e)
    {

        hdc = new HarleyDavidson(con);
        var sonuc = from a in hdc.IkinciEl select a;

        dgvIkinciEl.DataSource = sonuc.ToList();

        //var bindingSource = new BindingSource();
        //bindingSource.DataSource = sonuc.ToList();
        //dgvIkinciEl.DataSource = bindingSource;
    }

this.dgvIkinciEl.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
        this.dgvIkinciEl.Location = new System.Drawing.Point(3, 3);
        this.dgvIkinciEl.Name = "dgvIkinciEl";
        this.dgvIkinciEl.Size = new System.Drawing.Size(648, 247);
        this.dgvIkinciEl.TabIndex = 0;

帮助。当我显示refreshToken()

 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"*/};

我注意到有些Feed有错误的价值。

相关问题