這幾天朋友想實做Google Task API ,但是在一開始就遇到了問題,仔細研究後發現似乎是Google 提供的Example Code 有錯。
參考資料
Google Apps Tasks API: Instantiate a Client
在Step2的地方
AccessTokenResponse response = new GoogleAuthorizationCodeGrant(httpTransport, jsonFactory, clientId, clientSecret, code, redirectUrl).execute();
在API中並不能這樣建立TokenResponse,所以我把他改成下列模式
GoogleTokenResponse response = new GoogleAuthorizationCodeTokenRequest(httpTransport, jsonFactory, clientId, clientSecret, code, redirectUrl).execute();
如此就可以順利運行了