API 인증 및 승인이 처리되는 방식에 대한 기본 사항을 이해하는 것이 중요합니다.
모든 API 호출은 단순 액세스 또는 승인된 액세스 (아래에 정의됨)를 사용해야 합니다.
많은 API 메서드에는 승인된 액세스가 필요하지만 일부는 사용할 수 있습니다.
둘 중 하나를 사용할 수 있는 일부 API 메서드는 다르게 동작할 수 있지만
간단한 액세스와 승인된 액세스 중 무엇을 사용하는지에 따라 다릅니다.
적절한 액세스 유형을 확인하려면 API의 메서드 문서를 참조하세요.
1. 단순 API 액세스 (API 키)
이러한 API 호출은 비공개 사용자 데이터에 액세스하지 않습니다.
애플리케이션은 자체 애플리케이션에 속하는 애플리케이션으로 자신을 인증해야 합니다.
API 콘솔 프로젝트에 추가합니다
이는 회계 목적으로 프로젝트 사용량을 측정하는 데 필요합니다.
API 키:
애플리케이션을 인증하려면
API 키
'API 콘솔 프로젝트'를 참조하세요.
애플리케이션에서 실행하는 모든 단순 액세스 호출에 이 키가 포함되어야 합니다.
<ph type="x-smartling-placeholder">
2. 승인된 API 액세스 (OAuth 2.0)
이러한 API 호출은 비공개 사용자 데이터에 액세스합니다.
전화를 걸기 전에
개인 데이터에 대한 액세스 권한이 있는 사용자가 귀하의 애플리케이션 액세스를 허용해야 합니다.
따라서 애플리케이션은
사용자가 애플리케이션에 대한 액세스 권한을 부여해야 합니다.
이 액세스 권한을 부여하려면 사용자가 인증되어야 합니다.
이 모든 것은
OAuth 2.0 및 이를 위해 작성된 라이브러리.
범위:
각 API는 허용된 작업 집합을 선언하는 하나 이상의 범위를 정의합니다.
예를 들어 API에 읽기 전용 및 읽기-쓰기 범위가 있을 수 있습니다.
애플리케이션이 사용자 데이터에 대한 액세스를 요청할 때
요청에는 하나 이상의 범위가 포함되어야 합니다.
사용자는 애플리케이션에서 요청하는 액세스 범위를 승인해야 합니다.
갱신 및 액세스 토큰:
사용자가 애플리케이션에 액세스를 허용하면 OAuth 2.0 인증 서버가
애플리케이션에 갱신 및 액세스 토큰을 제공합니다.
이러한 토큰은 요청된 범위에서만 유효합니다.
애플리케이션은 액세스 토큰을 사용하여 API 호출을 승인합니다.
액세스 토큰은 만료되지만 갱신 토큰은 만료되지 않습니다.
애플리케이션은 갱신 토큰을 사용하여 새 액세스 토큰을 얻을 수 있습니다.
<ph type="x-smartling-placeholder">
클라이언트 ID 및 클라이언트 보안 비밀번호:
이러한 문자열은 애플리케이션을 고유하게 식별하며 토큰을 획득하는 데 사용됩니다.
API 콘솔에서 프로젝트에 대해 생성됩니다.
클라이언트 ID에는 세 가지 유형이 있습니다.
따라서 애플리케이션에 맞는 올바른 유형을 가져와야 합니다.
이 API는 두 가지 유형의 사용자 인증 정보를 지원합니다.
프로젝트에 적합한 사용자 인증 정보를 만듭니다.
<ph type="x-smartling-placeholder">
</ph>
OAuth 2.0: 애플리케이션에서 비공개 사용자 데이터를 요청할 때마다 요청과 함께 OAuth 2.0 토큰을 보내야 합니다. 애플리케이션은 먼저 토큰을 획득하기 위해 클라이언트 ID나 클라이언트 보안 비밀번호를 보냅니다. 웹 애플리케이션, 서비스 계정, 설치된 애플리케이션의 OAuth 2.0 사용자 인증 정보를 생성할 수 있습니다.
API 키: OAuth 2.0 토큰을 제공하지 않는 요청은 API 키를 전송해야 합니다.
키는 프로젝트를 식별하고 API 액세스, 할당량, 보고서를 제공합니다.
API는 여러 유형의 API 키 제한 사항을 지원합니다. 필요한 API 키가 아직 없는 경우 사용자 인증 정보 만들기 > API 키를 클릭하여 Console에서 API 키를 만듭니다. 프로덕션 단계에서 사용하기 전에 키 제한을 클릭하고 제한사항 중 하나를 선택하여 키를 제한할 수 있습니다.
usingSystem;usingSystem.Threading.Tasks;usingGoogle.Apis.Discovery.v1;usingGoogle.Apis.Discovery.v1.Data;usingGoogle.Apis.Services;namespaceDiscovery.ListAPIs{///<summary>
///ThisexampleusesthediscoveryAPItolistallAPIsinthediscoveryrepository.///https://developers.google.com/discovery/v1/using.///<summary>
classProgram{[STAThread]staticvoidMain(string[]args){Console.WriteLine("Discovery API Sample");Console.WriteLine("====================");try{newProgram().Run().Wait();}catch(AggregateExceptionex){foreach(vareinex.InnerExceptions){Console.WriteLine("ERROR: "+e.Message);}}Console.WriteLine("Press any key to continue...");Console.ReadKey();}privateasyncTaskRun(){//Createtheservice.varservice=newDiscoveryService(newBaseClientService.Initializer{ApplicationName="Discovery Sample",ApiKey="[YOUR_API_KEY_HERE]",});//Runtherequest.Console.WriteLine("Executing a list request...");varresult=awaitservice.Apis.List().ExecuteAsync();//Displaytheresults.if(result.Items!=null){foreach(DirectoryList.ItemsDataapiinresult.Items){Console.WriteLine(api.Id+" - "+api.Title);}}}}}
서비스의 인스턴스를 생성하려면 생성자를 호출하기만 하면 됩니다. 예를 들면 new TasksService(new BaseClientService.Initializer {...});"입니다.
서비스의 모든 메서드는 서비스 객체 자체의 개별 리소스에 있습니다.
검색 서비스에는 List 메서드가 포함된 Apis 리소스가 있습니다.
service.Apis.List(..)를 호출하면 이 메서드를 타겟팅하는 요청 객체가 반환됩니다.
요청을 실행하려면 요청에서 Execute() 또는 ExecuteAsyc() 메서드를 호출합니다.
BaseClientService.Initializer 인스턴스에서 ApiKey 속성을 사용하여 API 키를 설정합니다.
API에 대한 정보 찾기
이
지원되는 API
페이지에는 이 라이브러리를 사용하여 액세스할 수 있는 모든 API와 문서 링크가 나열됩니다.
또한
API 탐색기
를 사용하여 API를 탐색하고 사용 가능한 메서드를 나열하며 브라우저에서 API 호출을 시도해 볼 수도 있습니다.
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThis documentation provides an overview of using the Google API client library for .NET, including setup, authentication, and usage examples.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the library, ensure you have a Google account, a Google API Console project, and install the necessary NuGet package.\u003c/p\u003e\n"],["\u003cp\u003eThe library supports both simple API access using API keys and authorized access with OAuth 2.0 for private user data.\u003c/p\u003e\n"],["\u003cp\u003eSimple API access requires an API key for project usage tracking, while authorized access necessitates OAuth 2.0 for user data access.\u003c/p\u003e\n"],["\u003cp\u003eExamples are provided for basic API usage and guidance on locating further information about supported APIs and the APIs Explorer is included.\u003c/p\u003e\n"]]],[],null,["This document provides all the basic information you need to start using the library.\nIt covers the library concepts,\nshows examples for various use cases,\nand gives links to more information.\n\nSetup\n\n\nThere are a few setup steps you need to complete before you can use this library:\n\n1. If you don't already have a Google account, [sign up](https://www.google.com/accounts).\n2. If you have never created a Google API Console project, read the [Managing Projects page](/console/help/managing-projects) and create a project in the [Google API Console](https://console.cloud.google.com/).\n3. [Install](http://www.nuget.org/packages?q=google.apis&prerelease=true&sortOrder=relevance) the NuGet package you want to work with.\n\nAuthentication and authorization\n\n\nIt is important to understand the basics of how API authentication and authorization are handled.\nAll API calls must use either simple or authorized access (defined below).\nMany API methods require authorized access, but some can use either.\nSome API methods that can use either behave differently,\ndepending on whether you use simple or authorized access.\nSee the API's method documentation to determine the appropriate access type.\n\n1. Simple API access (API keys)\n\n\nThese API calls do not access any private user data.\nYour application must authenticate itself as an application belonging\nto your Google API Console project.\nThis is needed to measure project usage for accounting purposes.\n\n\n**API key** :\nTo authenticate your application, use an\n[API key](/console/help/using-keys)\nfor your API Console project.\nEvery simple access call your application makes must include this key.\n| **Warning**: Keep your API key private. If someone obtains your key, they could use it to consume your quota or incur charges against your API Console project.\n\n\u003cbr /\u003e\n\n2. Authorized API access (OAuth 2.0)\n\n\nThese API calls access private user data.\nBefore you can call them,\nthe user that has access to the private data must grant your application access.\nTherefore, your application must be authenticated,\nthe user must grant access for your application,\nand the user must be authenticated in order to grant that access.\nAll of this is accomplished with\n[OAuth 2.0](/accounts/docs/OAuth2) and libraries written for it.\n\n\n**Scope**:\nEach API defines one or more scopes that declare a set of operations permitted.\nFor example, an API might have read-only and read-write scopes.\nWhen your application requests access to user data,\nthe request must include one or more scopes.\nThe user needs to approve the scope of access your application is requesting.\n\n\n**Refresh and access tokens**:\nWhen a user grants your application access, the OAuth 2.0 authorization server\nprovides your application with refresh and access tokens.\nThese tokens are only valid for the scope requested.\nYour application uses access tokens to authorize API calls.\nAccess tokens expire, but refresh tokens do not.\nYour application can use a refresh token to acquire a new access token.\n| **Warning**: Keep refresh and access tokens private. If someone obtains your tokens, they could use them to access private user data.\n\n\u003cbr /\u003e\n\n\n**Client ID and client secret** :\nThese strings uniquely identify your application and are used to acquire tokens.\nThey are created for your project on the [API Console](https://console.cloud.google.com/).\nThere are three types of client IDs,\nso be sure to get the correct type for your application:\n\n- [Web application](/accounts/docs/OAuth2WebServer) client IDs\n- [Installed application](/accounts/docs/OAuth2InstalledApp) client IDs\n- [Service Account](/accounts/docs/OAuth2ServiceAccount) client IDs\n\n| **Warning**: Keep your client secret private. If someone obtains your client secret, they could use it to consume your quota, incur charges against your Console project, and request access to user data.\n\n\u003cbr /\u003e\n\nExamples\n\n\nIn this section, there are examples of simple API usage without authorization.\nFor more information about authorization calls, see the\n[OAuth 2.0 page for .NET](/api-client-library/dotnet/guide/aaa_oauth).\n\nSimple API example\n\n\nThis example uses simple API access for a command-line application.\nIt calls the\n[Google Discovery API](/discovery) to list all Google APIs.\n\nSetup for example\n\n\n**Get your Simple API key**. To find your application's API key, do the following:\n\n\n1. Open the [Credentials page](https://console.cloud.google.com/apis/credentials) in the API Console.\n2. This API supports two types of credentials. Create whichever credentials are appropriate for your project:\n - **OAuth 2.0:** Whenever your application requests private user\n data, it must send an OAuth 2.0 token along with the request. Your\n application first sends a client ID and, possibly, a client secret to\n obtain a token. You can generate OAuth 2.0 credentials for web\n applications, service accounts, or installed applications.\n\n For more information, see the [OAuth 2.0 documentation](https://developers.google.com/identity/protocols/OAuth2).\n - **API keys:**\n\n A request that does not provide an OAuth 2.0 token must send an API\n key.\n\n The key identifies your project and provides API access, quota, and\n reports.\n\n The API supports several types of restrictions on API keys. If the API key that you\n need doesn't already exist, then create an API key in the Console by\n clicking **[Create credentials](https://console.cloud.google.com/apis/credentials) \\\u003e API key** . You can restrict the key before using it\n in production by clicking **Restrict key** and selecting one of the\n **Restrictions**.\n\nTo keep your API keys secure, follow the [best practices for\nsecurely using API keys](//cloud.google.com/docs/authentication/api-keys).\n\n\u003cbr /\u003e\n\nCode for example \n\n```transact-sql\nusing System;\nusing System.Threading.Tasks;\n\nusing Google.Apis.Discovery.v1;\nusing Google.Apis.Discovery.v1.Data;\nusing Google.Apis.Services;\n\nnamespace Discovery.ListAPIs\n{\n /// \u003csummary\u003e\n /// This example uses the discovery API to list all APIs in the discovery repository.\n /// https://developers.google.com/discovery/v1/using.\n /// \u003csummary\u003e\n class Program\n {\n [STAThread]\n static void Main(string[] args)\n {\n Console.WriteLine(\"Discovery API Sample\");\n Console.WriteLine(\"====================\");\n try\n {\n new Program().Run().Wait();\n }\n catch (AggregateException ex)\n {\n foreach (var e in ex.InnerExceptions)\n {\n Console.WriteLine(\"ERROR: \" + e.Message);\n }\n }\n Console.WriteLine(\"Press any key to continue...\");\n Console.ReadKey();\n }\n\n private async Task Run()\n {\n // Create the service.\n var service = new DiscoveryService(new BaseClientService.Initializer\n {\n ApplicationName = \"Discovery Sample\",\n ApiKey=\"[YOUR_API_KEY_HERE]\",\n });\n\n // Run the request.\n Console.WriteLine(\"Executing a list request...\");\n var result = await service.Apis.List().ExecuteAsync();\n\n // Display the results.\n if (result.Items != null)\n {\n foreach (DirectoryList.ItemsData api in result.Items)\n {\n Console.WriteLine(api.Id + \" - \" + api.Title);\n }\n }\n }\n }\n}\n```\n\n\nTips for using API keys:\n\n- In order to use a specific service, you have to add a reference to it. For example if you want to use the [Tasks API](https://developers.google.com/google-apps/tasks/), you should install its NuGet package [Google.Apis.Tasks.v1](http://www.nuget.org/packages/Google.Apis.Tasks.v1/).\n- To create an instance of a service, just call its constructor. For example: `new TasksService(new BaseClientService.Initializer {...});\"`.\n- All methods of a service are located on individual resources on the service object itself. The Discovery service has an `Apis` resource, which contains a `List` method. When you call `service.Apis.List(..)` a request object targeting this method is returned. \n To execute a request, call the `Execute()` or `ExecuteAsyc()` method on a request.\n- Set the API key using the `ApiKey` property on the `BaseClientService.Initializer` instance.\n\nFinding information about the APIs\n\n\nThe\n[Supported APIs](/api-client-library/dotnet/apis)\npage lists all APIs that can be accessed using this library as well as links to documentation.\n\n\nYou can also use the\n[APIs Explorer](/apis-explorer)\nto browse APIs, list available methods, and even try API calls from your browser."]]