クライアントクレデンシャルグラントタイプ(2-legged OAuth)
アプリが自身に代わって動作することを認可します。
本 API および本ドキュメントを利用し、連携を構築することにより、Additional API Terms and Guidelines に同意したものとみなされます。
クライアントクレデンシャルグラントタイプ(2-legged OAuth)の概要
Indeed パートナーになると、Indeed は Indeed API とサービスをお客様のプロダクトに連携するアプリをセットアップします。Partner Console でアプリとその OAuth クレデンシャル(クライアント ID と client secret)を確認し、それらのクレデンシャルをアクセストークンと交換して Indeed API 呼び出しを認証します。
次のこともできます。
- 雇用主を表すアクセストークンを取得する。
- 自社に代わって動作することをアプリに認可する。
- 別の会社が自社に代わって動作できるようにする。
Indeedパートナーになる
まだパートナーでない場合は、Indeed パートナーになる をご覧ください。
OAuth クレデンシャルを取得する
-
Indeed ユーザーアカウントで Partner Console にサインインします。
アプリ詳細ページの Credentials タブに、OAuth クレデンシャル(クライアント ID と client secret)が表示されます。
アクセストークンを取得する
アクセストークンを取得するには、curl などのコマンドラインツールや Insomnia などの UI ツールを使用して、次のヘッダーとボディパラメーターで https://apis.indeed.com/oauth/v2/tokens に POST リクエストを送信します。
クライアントシークレットをエンドユーザーに公開しないでください。Indeed は、バックエンドでトークンを生成することを推奨します。
curl -L 'https://apis.indeed.com/oauth/v2/tokens' \ -H 'Accept: application/json' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'client_id=<client_id>' \ -d 'client_secret=<client_secret>' \ -d 'grant_type=client_credentials' \ -d 'scope=employer_access'リクエストヘッダーは次のとおりです。
リクエストボディのパラメーターは次のとおりです。
{ "access_token": "<access_token>", "scope": "employer_access", "token_type": "Bearer", "expires_in": 3600}トークンは 1 時間(3600 秒)で有効期限が切れます。トークンは 1 時間ごとに更新します。
Indeed API を呼び出す
Indeed GraphQL APIを呼び出すには、以下のヘッダーとGraphQLクエリまたはミューテーションを指定してhttps://apis.indeed.com/graphqlにPOSTリクエストを送信します。
curl -L 'https://apis.indeed.com/graphql' \ -H 'Authorization: Bearer <access_token>' \ -H 'Content-Type: application/json' \ -d '{"query":"query {\n jobSearch(\n location: { radius: 5, radiusUnit: MILES, where: \"Austin\" }\n what: \"Nurse\"\n limit: 5\n ) {\n results {\n job {\n title\n sourceEmployerName\n }\n }\n }\n}","variables":{}}'リクエストヘッダー:
| ヘッダー | 値 | 説明 |
|---|---|---|
|
| Use this header to authenticate with the server and access protected resources. Pass the access token in this header with the For the See Get an access token, Authorization header, and Basic authentication scheme. |
|
| The media type of the resource. See Content-Type header. |
-dパラメーターでGraphQLクエリを指定します。
query { jobSearch(location: { radius: 5, radiusUnit: MILES, where: "Austin" } what: "Nurse" limit: 5) { results { job { title sourceEmployerName } } }}{ "errors": [{ "message": "The client does not have access to the 'job-retrieval-service' service.", "extensions": { "code": "INTERNAL_SERVER_ERROR" } }], "data": null}