mirror of
https://iceshrimp.dev/Crimekillz/jointrashposs.git
synced 2024-11-24 09:49:06 +01:00
c61ebe1a51
* New translations 1.about-misskey.md (Chinese Simplified) * New translations 1.about-misskey.md (Chinese Traditional) * New translations 1.index.md (Chinese Simplified) * New translations 1.index.md (Chinese Traditional) * New translations 0.index.md (Chinese Simplified) * New translations 0.index.md (Chinese Traditional) * New translations 1.warning.md (Chinese Simplified) * New translations 1.warning.md (Chinese Traditional) * New translations 2.get-started.md (Chinese Simplified) * New translations 2.get-started.md (Chinese Traditional) * New translations 3.join-server.md (Chinese Simplified) * New translations 3.join-server.md (Chinese Traditional) * New translations 4.things-to-know.md (Chinese Simplified) * New translations 4.things-to-know.md (Chinese Traditional) * New translations 1.index.md (Chinese Simplified) * New translations 1.index.md (Chinese Traditional) * New translations ads.md (Chinese Simplified) * New translations ads.md (Chinese Traditional) * New translations antenna.md (Chinese Simplified) * New translations antenna.md (Chinese Traditional) * New translations charts.md (Chinese Simplified) * New translations charts.md (Chinese Traditional) * New translations clip.md (Chinese Simplified) * New translations clip.md (Chinese Traditional) * New translations custom-emoji.md (Chinese Simplified) * New translations custom-emoji.md (Chinese Traditional) * New translations deck.md (French) * New translations deck.md (Italian) * New translations deck.md (Korean) * New translations deck.md (Polish) * New translations deck.md (Chinese Simplified) * New translations deck.md (Chinese Traditional) * New translations deck.md (English) * New translations drive.md (Chinese Simplified) * New translations drive.md (Chinese Traditional) * New translations favorite.md (Chinese Simplified) * New translations favorite.md (Chinese Traditional) * New translations follow.md (Chinese Simplified) * New translations follow.md (Chinese Traditional) * New translations hashtag.md (Chinese Simplified) * New translations hashtag.md (Chinese Traditional) * New translations mention.md (Chinese Simplified) * New translations mention.md (Chinese Traditional) * New translations mfm.md (Chinese Simplified) * New translations mfm.md (Chinese Traditional) * New translations mute-and-block.md (Chinese Simplified) * New translations mute-and-block.md (Chinese Traditional) * New translations pages.md (Chinese Simplified) * New translations pages.md (Chinese Traditional) * New translations plugin.md (Chinese Simplified) * New translations plugin.md (Chinese Traditional) * New translations poll.md (Chinese Simplified) * New translations poll.md (Chinese Traditional) * New translations reaction.md (Chinese Simplified) * New translations reaction.md (Chinese Traditional) * New translations share-form.md (Chinese Simplified) * New translations share-form.md (Chinese Traditional) * New translations silence.md (Chinese Simplified) * New translations silence.md (Chinese Traditional) * New translations theme.md (Chinese Simplified) * New translations theme.md (Chinese Traditional) * New translations thread-mute.md (Chinese Simplified) * New translations thread-mute.md (Chinese Traditional) * New translations timeline.md (Chinese Simplified) * New translations timeline.md (Chinese Traditional) * New translations webhook.md (French) * New translations webhook.md (Italian) * New translations webhook.md (Korean) * New translations webhook.md (Polish) * New translations webhook.md (Chinese Simplified) * New translations webhook.md (Chinese Traditional) * New translations webhook.md (English) * New translations widgets.md (Chinese Simplified) * New translations widgets.md (Chinese Traditional) * New translations word-mute.md (French) * New translations word-mute.md (Italian) * New translations word-mute.md (Korean) * New translations word-mute.md (Polish) * New translations word-mute.md (Chinese Simplified) * New translations word-mute.md (Chinese Traditional) * New translations word-mute.md (English) * New translations 1.troubleshooting.md (Chinese Simplified) * New translations 1.troubleshooting.md (Chinese Traditional) * New translations apps.md (Chinese Simplified) * New translations apps.md (Chinese Traditional) * New translations donate.md (French) * New translations donate.md (Italian) * New translations donate.md (Korean) * New translations donate.md (Polish) * New translations donate.md (Chinese Simplified) * New translations donate.md (Chinese Traditional) * New translations donate.md (English) * New translations faq.md (Chinese Simplified) * New translations faq.md (Chinese Traditional) * New translations glossary.md (Chinese Simplified) * New translations glossary.md (Chinese Traditional) * New translations misskey-hub.md (Chinese Simplified) * New translations misskey-hub.md (Chinese Traditional) * New translations 1.index.md (Chinese Simplified) * New translations 1.index.md (Chinese Traditional) * New translations announcement.md (Chinese Simplified) * New translations announcement.md (Chinese Traditional) * New translations ftt.md (Chinese Simplified) * New translations ftt.md (Chinese Traditional) * New translations role.md (French) * New translations role.md (Italian) * New translations role.md (Korean) * New translations role.md (Polish) * New translations role.md (Chinese Simplified) * New translations role.md (Chinese Traditional) * New translations role.md (English) * New translations 1.index.md (Chinese Simplified) * New translations 1.index.md (Chinese Traditional) * New translations bash.md (French) * New translations bash.md (Italian) * New translations bash.md (Korean) * New translations bash.md (Polish) * New translations bash.md (Chinese Simplified) * New translations bash.md (Chinese Traditional) * New translations bash.md (English) * New translations docker.md (French) * New translations docker.md (Italian) * New translations docker.md (Korean) * New translations docker.md (Polish) * New translations docker.md (Chinese Simplified) * New translations docker.md (Chinese Traditional) * New translations docker.md (English) * New translations kubernetes.md (French) * New translations kubernetes.md (Italian) * New translations kubernetes.md (Korean) * New translations kubernetes.md (Polish) * New translations kubernetes.md (Chinese Simplified) * New translations kubernetes.md (Chinese Traditional) * New translations kubernetes.md (English) * New translations manual.md (Chinese Simplified) * New translations manual.md (Chinese Traditional) * New translations ubuntu-manual.md (Chinese Simplified) * New translations ubuntu-manual.md (Chinese Traditional) * New translations cdn.md (Chinese Simplified) * New translations cdn.md (Chinese Traditional) * New translations nginx.md (Chinese Simplified) * New translations nginx.md (Chinese Traditional) * New translations push-docker-hub.md (French) * New translations push-docker-hub.md (Italian) * New translations push-docker-hub.md (Korean) * New translations push-docker-hub.md (Polish) * New translations push-docker-hub.md (Chinese Simplified) * New translations push-docker-hub.md (Chinese Traditional) * New translations push-docker-hub.md (English) * New translations scale-out.md (Chinese Simplified) * New translations scale-out.md (Chinese Traditional) * New translations troubleshooting.md (Chinese Simplified) * New translations troubleshooting.md (Chinese Traditional) * New translations disable-timelines.md (Chinese Simplified) * New translations disable-timelines.md (Chinese Traditional) * New translations 1.index.md (Chinese Simplified) * New translations 1.index.md (Chinese Traditional) * New translations libraries.md (Chinese Simplified) * New translations libraries.md (Chinese Traditional) * New translations permission.md (Chinese Simplified) * New translations permission.md (Chinese Traditional) * New translations 1.index.md (Chinese Simplified) * New translations 1.index.md (Chinese Traditional) * New translations 1.index.md (Chinese Simplified) * New translations 1.index.md (Chinese Traditional) * New translations global-timeline.md (French) * New translations global-timeline.md (Italian) * New translations global-timeline.md (Korean) * New translations global-timeline.md (Polish) * New translations global-timeline.md (Chinese Simplified) * New translations global-timeline.md (Chinese Traditional) * New translations global-timeline.md (English) * New translations home-timeline.md (French) * New translations home-timeline.md (Italian) * New translations home-timeline.md (Korean) * New translations home-timeline.md (Polish) * New translations home-timeline.md (Chinese Simplified) * New translations home-timeline.md (Chinese Traditional) * New translations home-timeline.md (English) * New translations hybrid-timeline.md (French) * New translations hybrid-timeline.md (Italian) * New translations hybrid-timeline.md (Korean) * New translations hybrid-timeline.md (Polish) * New translations hybrid-timeline.md (Chinese Simplified) * New translations hybrid-timeline.md (Chinese Traditional) * New translations hybrid-timeline.md (English) * New translations index.md (Chinese Simplified) * New translations index.md (Chinese Traditional) * New translations local-timeline.md (French) * New translations local-timeline.md (Italian) * New translations local-timeline.md (Korean) * New translations local-timeline.md (Polish) * New translations local-timeline.md (Chinese Simplified) * New translations local-timeline.md (Chinese Traditional) * New translations local-timeline.md (English) * New translations main.md (French) * New translations main.md (Italian) * New translations main.md (Korean) * New translations main.md (Polish) * New translations main.md (Chinese Simplified) * New translations main.md (Chinese Traditional) * New translations main.md (English) * New translations note-capture-events.md (French) * New translations note-capture-events.md (Italian) * New translations note-capture-events.md (Korean) * New translations note-capture-events.md (Polish) * New translations note-capture-events.md (Chinese Simplified) * New translations note-capture-events.md (Chinese Traditional) * New translations note-capture-events.md (English) * New translations token.md (Chinese Simplified) * New translations token.md (Chinese Traditional) * New translations 1.index.md (Chinese Simplified) * New translations 1.index.md (Chinese Traditional) * New translations create-plugin.md (Chinese Simplified) * New translations create-plugin.md (Chinese Traditional) * New translations plugin-api-reference.md (Chinese Simplified) * New translations plugin-api-reference.md (Chinese Traditional) * New translations publish-on-your-website.md (Chinese Simplified) * New translations publish-on-your-website.md (Chinese Traditional) * New translations 5.releases.md (Chinese Simplified) * New translations 5.releases.md (Chinese Traditional)
126 lines
5.7 KiB
Markdown
126 lines
5.7 KiB
Markdown
# アクセストークンの取得
|
||
|
||
APIを使い始めるには、APIを利用するアカウントに紐づいた**アクセストークン**を取得する必要があります。
|
||
このドキュメントでは、アクセストークンを取得する手順を説明した後、基本的なAPIの使い方を説明します。
|
||
|
||
基本的に、APIはリクエストにはアクセストークンが必要となります。
|
||
アクセストークンは、ユーザーに紐づいた認証情報で、APIを利用するユーザーを識別するとともに、アクセストークンごとにどういった操作の権限を持っているかが管理されます。
|
||
|
||
:::tip
|
||
ユーザーとそのユーザーに紐づいたアクセストークンは一対多の関係であり、あるユーザーに対して複数のアクセストークンが発行され得ます。
|
||
:::
|
||
|
||
あなた自分自身のアクセストークンは簡単に取得できるほか、あなたのアプリケーションを使用することになる不特定のユーザーのアクセストークンを取得することもできます。
|
||
|
||
- 前者の場合: **「自分自身のアクセストークンを手動発行する」** に進む
|
||
- 後者の場合: **「アプリケーション利用者にアクセストークンの発行をリクエストする」** に進む
|
||
|
||
### 自分自身のアクセストークンを手動発行する
|
||
|
||
Misskey Webの「設定 > API」で、自分のアクセストークンを発行できます。
|
||
|
||
:::danger
|
||
アクセストークンは他人に知られないようにしてください。
|
||
:::
|
||
|
||
### アプリケーション利用者にアクセストークンの発行をリクエストする
|
||
|
||
アプリケーションを利用するユーザー(以下単に「ユーザー」と呼びます)のアクセストークンを取得するには、以下の手順で発行をリクエストします。
|
||
|
||
:::tip
|
||
|
||
以下に説明する方法は、アプリを作成せずインスタントにアクセストークンを発行する、MiAuthと呼ばれるものです。
|
||
|
||
[アプリ作成方式でのアクセストークン取得方法もあります(旧来型)。](./app)
|
||
:::
|
||
|
||
#### Step 1
|
||
|
||
UUIDを生成する。以後これを**セッションID**と呼びます。
|
||
|
||
:::danger
|
||
このセッションIDは毎回生成し、使いまわさないようにしてください。
|
||
:::
|
||
|
||
#### Step 2
|
||
|
||
アプリケーション認証フォームをユーザーのブラウザで表示させる。認証フォームは、以下の形式のURLで開くことができます:
|
||
|
||
```
|
||
https://{host}/miauth/{session}
|
||
```
|
||
|
||
ここで、
|
||
|
||
- `{host}`の部分は、ユーザーのサーバーのホストに置き換えます。通常ホストはユーザーが入力します。
|
||
- `{session}`の部分は、セッションIDに置き換えます。
|
||
|
||
また、URLにクエリパラメータとしていくつかのオプションを設定できます:
|
||
|
||
| 名前 | 説明 |
|
||
| ------------ | ----------------------------------------------------------------------------- |
|
||
| `name` | アプリケーション名。 |
|
||
| `icon` | アプリケーションのアイコン画像URL。 |
|
||
| `callback` | 認証が終わった後にリダイレクトするURL。<br>リダイレクト時には、`session`というクエリパラメータでセッションIDが付きます。 |
|
||
| `permission` | アプリケーションが要求する権限。<br>要求する権限を`,`で区切って列挙します。権限の一覧は[こちら](./permission.md)で確認できます。 |
|
||
|
||
:::tip{label='例'}
|
||
|
||
```
|
||
https://misskey.io/miauth/c1f6d42b-468b-4fd2-8274-e58abdedef6f?name=MyApp&callback=https%3A%2F%2Fmyapp.example.com%2Fcallback&permission=write:notes,write:following,read:drive
|
||
```
|
||
|
||
:::
|
||
|
||
#### Step 3
|
||
|
||
ユーザーがアプリケーションアクセスを許可した後、次の形式のURLにPOSTリクエストすると、レスポンスとしてアクセストークンを含むJSONが返ります。
|
||
|
||
```
|
||
https://{host}/api/miauth/{session}/check
|
||
```
|
||
|
||
ここで、
|
||
|
||
- `{host}`の部分は、ユーザーのサーバーのホストに置き換えます。
|
||
- `{session}`の部分は、セッションIDに置き換えます。
|
||
|
||
レスポンスに含まれるプロパティは以下の通りです:
|
||
|
||
| 名前 | 説明 |
|
||
| ------- | -------------- |
|
||
| `token` | ユーザーのアクセストークン。 |
|
||
| `user` | ユーザーの情報。 |
|
||
|
||
## APIの利用
|
||
|
||
アクセストークンが取得できたら、各種エンドポイントにリクエストすることでAPIの利用が行えます。
|
||
|
||
:::tip
|
||
|
||
- HTTP APIはすべてPOSTで、リクエスト/レスポンスともにJSON形式です(drive/files/createを除く)。
|
||
- 要求ヘッダーに`Content-Type: application/json`を指定します。
|
||
- アクセストークンは、`i`というパラメータ名でリクエストボディJSONに含めます。
|
||
- ベースURLは`https://{サーバーのドメイン}/api`です。
|
||
|
||
:::
|
||
|
||
アクセストークン付きのボディの例(metaの場合):
|
||
|
||
```json
|
||
{
|
||
"i": "HogEFugA1341",
|
||
"detail": false
|
||
}
|
||
```
|
||
|
||
<!--TODO:「APIリファレンス」をリンクに差し替え-->
|
||
|
||
APIの詳細は、APIリファレンスを参照してください。
|
||
|
||
:::warning
|
||
MisskeyはRESTを採用していません。
|
||
:::
|
||
|
||
また、MisskeyはHTTP APIだけでなく、ストリーミングAPIも提供しています。ストリーミングAPIの詳細は[こちらのドキュメント](./streaming/index.md)を参照してください。
|