# How to get the tokens for various Docs type?

You can obtain them via URL or open API. The specific steps are shown below.

## Method 1: Obtain via Browser Address Bar.

The token is the red part in the following examples (**Note:** When copying, the URL might end with "==#==").
  - Folder **folder_token**: https://sample.feishu.cn/drive/folder/==cSJe2JgtFFBwRuTKAJK6baNGUn0==
  - File **file_token**: https://sample.feishu.cn/file/==ndqUw1kpjnGNNaegyqDyoQDCLx1==
  - Document **doc_token**: https://sample.feishu.cn/docs/==2olt0Ts4Mds7j7iqzdwrqEUnO7q==
  - New Document **document_id**: https://sample.feishu.cn/docx/==UXEAd6cRUoj5pexJZr0cdwaFnpd==
  - Spreadsheet **spreadsheet_token**: https://sample.feishu.cn/sheets/==MRLOWBf6J47ZUjmwYRsN8utLEoY==
  - Base **app_token**: https://sample.feishu.cn/base/==Pc9OpwAV4nLdU7lTy71t6Kmmkoz==
  - Wiki Space **space_id**: https://sample.feishu.cn/wiki/settings/==7075377271827264924== (Needs the knowledge base administrator to obtain this address from the settings page)
  - Wiki Node **node_token**: https://sample.feishu.cn/wiki/==sZdeQp3m4nFGzwqR5vx4vZksMoe==

## Method 2: Obtain via Open Platform API

To obtain the cloud document token via API, you need to determine where the current resource is mounted and then call the relevant API. For example, if the document is mounted in the knowledge base, you need to obtain the document token through the knowledge base related API. If you use the document related API, it will return an error. The specific steps are as follows:

### Obtain the token of resources in the "Cloud Space"

Resources in the cloud space refer to resources stored in the cloud disk (or folder). As shown in the figure below, this document resource is stored in the cloud disk and its cloud document type is a document (docx).

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/4e60279d12890fb9c90e8f75cc187a40_rjZnXuRMZL.png?height=155&lazyload=true&maxWidth=583&width=868)

1. Obtain the root folder token through [Get My Space (root folder) Metadata](https://open.feishu.cn/document/ukTMukTMukTM/ugTNzUjL4UzM14CO1MTN/get-root-folder-meta).
   2. Obtain the token of the cloud document resources in it through [Get the File List in the Folder](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/file/list).
   3. To read and write operations on these cloud document resources, you can further refer to [Document](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-overview), [Spreadsheet Overview](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview), [Bitable Overview](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/bitable-overview) to use the corresponding resource APIs.

### Obtain the token of resources in the "Knowledge Base"

Resources in the knowledge base refer to resources mounted in the knowledge base (wiki). As shown in the figure below, this document resource is a document mounted in the knowledge base.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/6d375705f169dd298fe6c8b4b624dd83_gpIlQGJuYz.png?height=478&lazyload=true&maxWidth=583&width=1625)

1.  （Optional）Obtain the **space_id** of the current knowledge space through [Get Knowledge Space List](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space/list).
   2. （Optional） Obtain the **node_token** of the current knowledge space node through [Get Sub-node List](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/list).
   3. Obtain the **obj_token** and **obj_type** of the cloud resources mounted under this node through [Get Knowledge Space Node Information](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space/get_node). At this time, the **obj_token** is the token of the cloud document.
   4. To read and write operations on these cloud document resources, you can further refer to [Document](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-overview), [Spreadsheet Overview](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview), [Bitable Overview](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/bitable-overview) to use the corresponding resource APIs.
### Obtain the token of embedded spreadsheets or bases in the "Document"

As shown in the figure below, the spreadsheet is embedded in the document (docx). You need to call the document-related API [Get All Blocks of the Document](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block/list) to obtain the token of the spreadsheet block.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/7d0ea09cc684c39f0678c8e6e0d1aeae_1df39ilsHf.png?height=608&lazyload=true&maxWidth=583&width=1334)

Among them:
   - The token of the spreadsheet block is in the format `spreadsheetToken_sheetId`. For example, in `Pc9OpwAV4nLdU7lTy71t6abcef_tblC63QuAGFabcef`, `Pc9OpwAV4nLdU7lTy71t6abcef` is the spreadsheetToken and `tblC63QuAGFabcef` is the sheet ID in the spreadsheet.
   - The token of the base block is in the format `appToken_tableId`. For example, in `appbcbWCzen6D8dezhoCH2abcef_tblC63QuAGFabcef`, `appbcbWCzen6D8dezhoCH2abcef` is the appToken and `tblC63QuAGFabcef` is the table ID in the base.

### Obtain the app_token of embedded bases in the "Spreadsheet"

Obtain the **app_token** and **tableId** of the embedded bases in the spreadsheet through [Get Spreadsheet Metadata](https://open.feishu.cn/document/ukTMukTMukTM/uETMzUjLxEzM14SMxMTN). Among them:

The token of the base block is in the format `appToken_tableId`. For example, in `appbcbWCzen6D8dezhoCH2abcef_tblC63QuAGFabcef`, `appbcbWCzen6D8dezhoCH2abcef` is the appToken and `tblC63QuAGFabcef` is the table ID in the base.

## Learn more
- [How to use application identity (tenant_access_token) to access cloud document resources](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN#dcf2fa2a)
- [How to use application identity (tenant_access_token) to access cloud document resources](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN#3374d789)
