本番環境では、Looker 管理者アカウントにバインドされた API 認証情報を使用しないでください。特に API アクティビティ(多くの場合に「サービス アカウント」と呼ばれます)用に最小限の権限のユーザー アカウントを作成し、それらのアカウントに API 認証情報を作成します。目的の API アクティビティに必要な権限のみを付与します。
HTTPS 認証
クライアント SDK を使用して認証の詳細を処理している場合でも、Looker API の認証の仕組みを確認することを必要とする場合があります。認証の詳細については、GitHub の Looker API の認証方法をご覧ください。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-22 UTC。"],[],[],null,["# Looker API authentication\n\n| **Note:** As of Looker 22.4, the [Looker API 4.0 is generally available](/looker/docs/api-4-ga). In Looker 23.18, the [Looker API 3.1 has been removed](/looker/docs/api-3x-deprecation).\n\nTo do anything with the Looker API, you'll first need to authenticate to it. The steps you'll need to take depend on whether or not you're using an SDK.\n\n\nAuthentication with an SDK\n--------------------------\n\nThis is the recommended method for API authentication:\n\n1. Create API credentials on the [Users page](/looker/docs/admin-panel-users-users) in the Admin section of your Looker instance. If you're not a Looker admin, ask your Looker admin to create the API credentials for you.\n\n API credentials are always bound to a Looker user account. API requests execute \"as\" the user associated with the API credentials. Calls to the API will only return data that the user is allowed to see, and modify only what the user is allowed to modify.\n2. The API credentials that you generated include a client ID and a client secret. You'll need to provide these to the SDK. The instructions for doing so can be found in the [SDK documentation](/looker/docs/api-sdk).\n\nThe SDK will then take care of obtaining the necessary access tokens and inserting them into all subsequent API requests.\n\n\nAuthentication without an SDK\n-----------------------------\n\nAPI authentication with an SDK is the recommended method. To authenticate without an SDK:\n\n1. Create API credentials on the [Users page](/looker/docs/admin-panel-users-users) in the Admin section of your Looker instance. If you're not a Looker admin, ask your Looker admin to create the API credentials for you.\n\n API credentials are always bound to a Looker user account. API requests execute \"as\" the user associated with the API credentials. Calls to the API will only return data that the user is allowed to see, and modify only what the user is allowed to modify.\n2. Obtain a short-term, OAuth 2.0 access token by calling the [`login`](/looker/docs/reference/looker-api/latest/methods/ApiAuth/login) endpoint of the API. You'll need to provide the API credentials that you generated in step 1, which include a client ID and a client secret.\n\n3. Place that access token into the HTTP authorization header of Looker API requests. An example Looker API request with an authorization header might look like this:\n\n GET /api/4.0/user HTTP/1.1\n Host: test.looker.com\n Date: Wed, 19 Oct 2023 12:34:56 -0700\n Authorization: token mt6Xc8jJC9GfJzKBQ5SqFZTZRVX8KY6k49TMPS8F\n\nThe OAuth 2.0 access token can be used on multiple API requests, until the access token expires or is invalidated by calling the [`logout`](/looker/docs/reference/looker-api/latest/methods/ApiAuth/logout) endpoint. API requests that use an expired access token will fail with a `401 Authorization Required` HTTP response.\n\nAPI interaction with user login settings\n----------------------------------------\n\nLooker API authentication is completely independent of Looker user login. User authentication protocols such as one-time passcodes (OTP, 2FA) and directory authentication (LDAP, SAML, and so on) don't apply to Looker API authentication.\n\nBecause of this, deleting a user's information from a user authentication protocol does not delete their API credentials. Using the procedures on the [Deleting Personal User Information](/looker/docs/deleting-personal-user-information) documentation page removes all of a user's personal data from Looker, preventing them from logging in at all, including through the API.\n\nManaging API credentials\n------------------------\n\n- Multiple sets of API credentials can be bound to a single Looker user account.\n- API credentials can be created and deleted without affecting the state of the user account.\n- Deleting a Looker user account invalidates all API credentials bound to the user account.\n- The API client secret must be kept private. Avoid storing API client secrets in source code or other places that can be seen by a lot of people.\n- In production, avoid using API credentials bound to Looker admin accounts. Create minimal privilege user accounts specifically for API activities (often called \"service accounts\") and create API credentials on those accounts. Grant only the permissions needed for the intended API activities.\n\nHTTPS authentication\n--------------------\n\nEven if you're using a client SDK to take care of the authentication details for you, you may still be curious about how Looker API authentication works. For low-level details about authentication, see [How to Authenticate to the Looker API](https://github.com/looker-open-source/looker-sdk-ruby/blob/master/authentication.md) on GitHub.\n\n\nAuthentication using OAuth\n--------------------------\n\nLooker can use the [Cross-Origin Resource Sharing (CORS)](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) protocol to let web applications make calls to the Looker API from outside a Looker instance's domain. See the [Looker API authentication using OAuth](/looker/docs/api-cors) documentation page for information about configuring CORS authentication."]]