-1
사용자 ID가있는 '간단한 데이터베이스'(Google 스프레드 시트)에 액세스해야하는 애플리케이션을 개발 중입니다.Google 스프레드 시트 API 키 예
나는 Oauth2.0으로 시도한다. 그러나 그것은 내가 필요한 것이 아니다. 나는 시트에 액세스하려면이 코드를 사용하고
:
private static SheetsService AuthorizeGoogleApp()
{
UserCredential credential;
using (var stream =
new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/sheets.googleapis.com-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
// Create Google Sheets API service.
var service = new SheetsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
return service;
}
그러나이 코드
는 C# 응용 프로그램은 자신의 구글 계정에 로그인 할 때 사용자에게 브라우저를 엽니 다.API를 통해 액세스해야하므로 사용자에게 투명합니다. 이미 api 키가 있지만 사용 방법을 모르며 Google 사이트에서 문서를 찾을 수 없습니다.
단순한 열을 읽는 데 도움이 될 수 있습니까?
미리 감사드립니다.
안녕하세요, Maurice, 설명서에 API 키가있는 작동 예제를 찾을 수 없습니다. 여기에 게시 할 수 있습니까? – ScaZ
내 API가 잘못되었습니다. API 키에 대한 설명은 다음에서 확인할 수 있습니다. https://developers.google.com/sheets/api/guides/authorizing#OAuth2Authorizing – Maurice
API 키를 사용하면 애플리케이션에 쿼리 매개 변수 key = yourAPIKey를 모두 추가 할 수 있습니다 요청 URL – Maurice