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

# SDKを使用したアプリトークン

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

<RelatedLinks
  title="必須のガイド"
  items={[
{ label: translate("Select Auth Method"), href: "/guides/authentication/select", badge: "GUIDE" },
{ label: translate("Setup with App Token Auth"), href: "/guides/authentication/app-token/app-token-setup", badge: "GUIDE" }
]}
/>

Box公式SDKには、アプリトークン認証のサポートが組み込まれています。

アプリトークン認証は、Box APIを直接操作するよう設計されており、ユーザーがアプリケーションを承認するためにBoxを介してリダイレクトする必要はありません。ただし、この認証はアプリケーションのデータのみに制限されています。

<Note>
  JWTを使用した認証方法は、もともとアプリケーションのサービスアカウントに関連付けられています。このトークンを使用して実行されるAPIコールはどれも、このアプリケーションから実行されているように見えますが、明示的なアクセス権がなければ他のユーザーのファイルやフォルダにはアクセスできません。
</Note>

## 前提条件

開始する前に、以下の手順を完了しておく必要があります。

* 開発者コンソール内でBoxアプリケーションを作成する
* アプリケーションがアプリトークン認証を使用するよう構成されていることを確認する
* アプリケーションのプライマリアプリトークンとセカンダリアプリトークンを生成し、コード内のどこかにこれらのトークンを保存する

## SDKクライアントの初期化

アプリトークン認証のためにSDKクライアントを初期化するには、SDKがインストールされていることを確認してから、以下のようにSDKを構成します。

<CodeGroup>
  ```csharp .Net theme={null}
  var config = new BoxConfig("[CLIENT_ID]", "", new Uri("http://localhost"));
  var session = new OAuthSession("[APP_TOKEN]", "N/A", 3600, "bearer");
  var client = new BoxClient(config, session);
  ```

  ```java Java theme={null}
  BoxTransactionalAPIConnection api = new BoxTransactionalAPIConnection("[APP_TOKEN]");
  ```

  ```python Python theme={null}
  from boxsdk import Client, OAuth2

  auth = OAuth2(access_token='[APP_TOKEN]')
  client = Client(auth)
  ```

  ```js Node theme={null}
  var BoxSDK = require('box-node-sdk');
  var sdk = new BoxSDK({
      clientID: '[CLIENT_ID]',
      clientSecret: ''
  });

  var client = sdk.getBasicClient('[APP_TOKEN]');
  ```
</CodeGroup>

これを使用すると、アプリケーションは、アプリトークン認証に対して有効になっている<Link href="/guides/authentication/app-token/endpoints">エンドポイント</Link>のいずれかにAPIコールを実行できます。

## SDKとアプリケーショントークンの使用

各SDKのアプリケーショントークンの詳細については、以下を参照してください。

* [.Net][.Net]

* [Java][Java]

* [Python][Python]

* [Node][Node]

[.Net]: https://github.com/box/box-windows-sdk-v2/blob/legacy/docs/authentication.md#box-view-authentication-with-app-tokens

[Java]: https://github.com/box/box-java-sdk/blob/legacy/doc/authentication.md#box-view-authentication-with-app-token

[Python]: https://github.com/box/box-python-sdk/blob/legacy/docs/usage/authentication.md#box-view-authentication-with-app-tokens

[Node]: https://github.com/box/box-node-sdk/blob/legacy/docs/authentication.md#box-view-authentication-with-app-tokens

<RelatedLinks
  title="関連するAPI"
  items={[
{ label: translate("Authorize user"), href: "/reference/get-authorize", badge: "GET" }
]}
/>

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("Downscope a Token"), href: "/guides/authentication/tokens/downscope", badge: "GUIDE" }
]}
/>
