> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 連絡先の権限スコープを取得する

> アプリの連絡先権限スコープを確認し、アクセス可能な部門と社員を把握できます

連絡先関連の API を呼び出す前に、連絡先 API 権限を追加する必要があります。本 API を使用して連絡先の権限スコープを取得できます。

## API 呼び出し説明

<Warning>
  本ドキュメントの API は旧バージョン仕様のサーバー API です。呼び出し方法については、旧バージョン API VS 新バージョン API をご参照ください。
</Warning>

連絡先関連の API を呼び出す前に、管理者は [DingTalk 開発者管理画面](https://open-dev.dingtalk.io/#/index) で対応する API 権限を申請し、これらの API が取得できる連絡先スコープを指定する必要があります。

下図のように、現在のアプリの access\_token は部門 A の連絡先を管理する権限のみを持っています。開発者は本 API を呼び出して、アプリの連絡先権限スコープを確認できます。開発者が連絡先 API を呼び出す際、権限スコープ内の社員の連絡先情報のみ取得でき、権限スコープ外の社員の連絡先情報を取得しようとすると `部門/社員が権限スコープ内にありません` というエラーが表示されます。

## リクエスト

| **基本情報**     |                                                                              |
| ------------ | ---------------------------------------------------------------------------- |
| HTTP URL     | [https://oapi.dingtalk.io/auth/scopes](https://oapi.dingtalk.io/auth/scopes) |
| HTTP Method  | GET                                                                          |
| サポートするアプリタイプ | appType-社内アプリ appType-サードパーティ社内アプリ                                           |
| 権限要件         | permission-qyapi\_base-企業 API を呼び出す際に必要な基本権限                                 |

### クエリパラメータ

| 名前            | タイプ    | 必須 | 例        | 説明                                                                                                                                                                                  |
| ------------- | ------ | -- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | はい | 6ed1bxxx | この API を呼び出すアプリ認証情報。   - 社内アプリは、[社内アプリの access\_token を取得する](/ja/open/development/obtain-orgapp-token) API を通じて取得します。 - サードパーティ社内アプリは、サードパーティ企業の access\_token を取得する API を通じて取得します。 |

### リクエスト例

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X GET "https://oapi.dingtalk.io/auth/scopes" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=2314cdxxxxbcd10713'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/auth/scopes");
OapiAuthScopesRequest req = new OapiAuthScopesRequest();
req.setHttpMethod("GET");
OapiAuthScopesResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiAuthScopesRequest("https://oapi.dingtalk.io/auth/scopes")
try:
	resp= req.getResponse(access_token)
	print(resp)
except Exception,e:
	print(e)
```

PHP

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_GET , DingTalkConstant::$FORMAT_JSON);
$req = new OapiAuthScopesRequest;
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/auth/scopes");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/auth/scopes");
OapiAuthScopesRequest req = new OapiAuthScopesRequest();
req.SetHttpMethod("GET");
OapiAuthScopesResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## レスポンス

### レスポンスボディ

| 名前                | タイプ           | 例                 | 説明                                 |
| ----------------- | ------------- | ----------------- | ---------------------------------- |
| auth\_org\_scopes | AuthOrgScopes |                   | 権限付与情報。                            |
| authed\_user      | String\[]     | \["user1","user"] | 連絡先情報を取得できる権限が付与された社員の userid リスト。 |
| authed\_dept      | Number\[]     | \[1,2,3]          | 連絡先情報を取得できる権限が付与された部門 ID リスト。      |
| auth\_user\_field | String\[]     | \["name","email"] | 取得を許可された企業ユーザーフィールド。               |
| errmsg            | String        | ok                | レスポンスコードの説明。                       |
| errcode           | Number        | 0                 | レスポンスコード。                          |

### レスポンスボディの例

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
        "errcode":0,
        "condition_field":[],
        "auth_user_field":[
                "jobnumber",
                "isLeader",
                "name",
                "position",
                "isAdmin",
                "avatar",
                "department",
                "userid",
                "deviceId",
                "isHide"
        ],
        "auth_org_scopes":{
                "authed_user":[],
                "authed_dept":[
                        1
                ]
        },
        "errmsg":"ok"
}
```

### エラーコード

この API の呼び出し時にエラーが発生した場合は、エラーメッセージをもとに [グローバルエラーコード](/ja/open/development/server-api-error-codes-1) ドキュメントで解決方法を検索してください。
