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

# login()

export const GitHubLink = ({url, compact = false}) => <a href={url} target="_blank" rel="noopener noreferrer" className={compact ? "source-link" : "github-source-link"}>
    {compact ? "View source" : <>
    <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
      <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
    </svg>
    GitHub source
      </>}
  </a>;

<GitHubLink compact url="https://github.com/wandb/wandb/blob/main/wandb/sdk/wandb_login.py#L20" />

<h2 id="function-wandblogin">
  <Badge color="blue" size="lg" shape="rounded">関数</Badge> wandb.login()
</h2>

W\&B にログインします。

通常、このメソッドを使用する必要はありません。認証を必要とするほとんどの W\&B メソッドは
暗黙的にログインできるためです。これは
`wandb login` CLI のプログラム版です。

このメソッドは、セッションのグローバルな認証情報を更新します (この呼び出し以降の現在の Python プロセスにおけるすべての wandb の使用に影響します) 。
また、.netrc ファイルも更新される場合があります。

WANDB\_IDENTITY\_TOKEN\_FILE 環境変数などを通じて
アイデンティティトークンファイルが設定されている場合、
セッションに使用されます (フェデレーションするアイデンティティ) 。APIキーは読み取られず、保存されません。

それ以外の場合、明示的な APIキーが提供されると、それが使用され、
システムの .netrc ファイルに書き込まれます。キーが提供されず、
セッションがすでに認証されている場合は、セッションキーが検証 (verify が
True の場合) に使用され、.netrc ファイルは更新されません。

上記のいずれも当てはまらない場合、APIキーは次の順序で取得されます：

* WANDB\_API\_KEY 環境変数
* システムまたは Workspace の設定ファイル内の api\_key 設定
* .netrc ファイル (~~/.netrc、~~/\_netrc、または
  NETRC 環境変数で指定されたパス)
* 利用可能で `prompt` が True の場合、インタラクティブプロンプト

```python theme={"system"}
key: 'str | None' = None,
relogin: 'bool | None' = None,
host: 'str | None' = None,
force: 'bool | None' = None,
timeout: 'int | None' = None,
verify: 'bool' = True,
referrer: 'str | None' = None,
prompt: 'bool' = True,
anonymous: 'DoNotSet' = DoNotSet
```

<h2 id="args">
  引数
</h2>

<ResponseField name="key" type="str | None">
  使用する APIキー。
</ResponseField>

<ResponseField name="relogin" type="bool | None">
  true の場合、.netrc や環境変数などを読み込まず、インタラクティブプロンプトから APIキー を取得します。
</ResponseField>

<ResponseField name="host" type="str | None">
  接続する W\&B サーバーの URL。
</ResponseField>

<ResponseField name="force" type="bool | None">
  true の場合、インタラクティブプロンプトでオフラインモードの選択を禁止します。
</ResponseField>

<ResponseField name="timeout" type="int | None">
  インタラクティブプロンプトでユーザー入力を待機する秒数。非インタラクティブな環境で誤ってインタラクティブプロンプトが表示された場合のフェイルセーフとして使用できます。
</ResponseField>

<ResponseField name="verify" type="bool">
  W\&B サーバーで認証情報を検証し、失敗時に AuthenticationError を発生させます。これは APIキー だけでなくアイデンティティトークンにも適用されます。
</ResponseField>

<ResponseField name="referrer" type="str | None">
  分析のために URL ログインリクエストで使用するリファラー。
</ResponseField>

<ResponseField name="prompt" type="bool">
  APIキー が設定されていない場合にインタラクティブに APIキー を要求するかどうか。False の場合、False を返し、セッションと設定を変更しません。
</ResponseField>

<ResponseField name="anonymous" type="DoNotSet">
  説明は提供されていません。
</ResponseField>

<h2 id="returns">
  Returns
</h2>

この呼び出しの後、セッションに認証情報がある場合に True を返します。

<h2 id="raises">
  送出される例外
</h2>

* `AuthenticationError`: 認証情報がサーバーでの検証に失敗した場合。
* `UsageError`: 認証情報が設定されておらず、`prompt` が True で、APIキーを尋ねる端末がない場合。
