[英]Coordinate API OAuth2 authentication with refresh token
我正在尋找一個示例代碼來使用OAuth2和現有的刷新令牌對Coordinate API進行身份驗證。 我在帶有服務帳戶的Google Coordinate OAuth2線程中尋找類似的內容。 我已經嘗試了該代碼段,但是由於dll沖突,我遇到了一些問題。 在nuget庫中,似乎已棄用了Google.Apis.Authentication.OAuth2
,我們應該改用Google.Apis.Auth
。
因此,如果有人可以提供與Google.Apis.Auth
一起使用的示例代碼,那就太好了。
請幫忙。
我可以通過嘗試不同的組合找到解決方案。 添加示例代碼,我認為這將有助於尋找相似解決方案的人。
using Google.Apis.Auth.OAuth2;
using Google.Apis.Coordinate.v1;
using Google.Apis.Coordinate.v1.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using (var stream = new FileStream(@"client_secret.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets,
new[] { CoordinateService.Scope.Coordinate },
"user", CancellationToken.None,new FileDataStore(folder));
}
var service = new CoordinateService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "appname",
});
var list = await service.Location.List("teamid", "team@mailid.com", 2000).ExecuteAsync();
希望這會有所幫助。
謝謝,MG
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.