我正在開發(fā)一個(gè)使用谷歌 API 從谷歌日歷獲取數(shù)據(jù)的網(wǎng)站,所以我從谷歌文檔中獲取了測試代碼并對其進(jìn)行了自定義。當(dāng)我在本地調(diào)試它時(shí),一切正常,它打開了一個(gè)新選項(xiàng)卡,并要求像它應(yīng)該的那樣訪問谷歌帳戶。這是我用于我得到的響應(yīng)令牌的方法:private static UserCredential GetCredential(){ UserCredential credential; var path = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "App_Data/credentials.json"); using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { string credPath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, ".credentials/calendar-access.json"); credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; } return credential;}我的問題出在服務(wù)器上,當(dāng)我第一次嘗試從谷歌獲取數(shù)據(jù)時(shí),頁面進(jìn)入無限循環(huán)。我擔(dān)心假設(shè)可以從谷歌帳戶訪問的選項(xiàng)卡正在服務(wù)器上打開,這就是為什么它會無限加載。所以我的問題是,首先,如果可能,如果可能,我該如何解決?其次,有沒有更好的方法呢?
在托管服務(wù)器上授予對 Google API 的訪問權(quán)限
繁星點(diǎn)點(diǎn)滴滴
2021-10-24 16:55:15