Skip to content

Commit dc28518

Browse files
committed
merge upstream
1 parent d75e946 commit dc28518

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

guide/authentication/index.md

+58
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
title: 認証
33
---
44

5+
<<<<<<< HEAD
56
このAPIにおいては、認証には2つの選択肢があり、基本的に以下のように選びましょう。
67

78
* そのサイトで有効化されたテーマやプラグインから利用するのであれば **クッキー認証**
89
* デスクトップアプリ、ウェブアプリ、モバイルアプリなどのサイトの外からアクセスするクライアントから API を利用するのであれば **OAuth 認証**
10+
=======
11+
There are several options for authenticating with the API. The basic choice boils
12+
down to:
13+
14+
* Are you a plugin/theme running on the site? Use **cookie authentication**
15+
* Are you a desktop/web/mobile client accessing the site externally? Use
16+
**OAuth authentication**, **application passwords**, or **basic authentication**.
17+
>>>>>>> upstream/gh-pages
918
1019
クッキー認証
1120
---------------------
@@ -21,6 +30,7 @@ title: 認証
2130
独自のデータモデルからアクセスする場合には、 `wp.api.models.Base` を継承することで、
2231
あらゆるカスタムリクエストで nonce がきちんと送信されることが保証されます。
2332

33+
<<<<<<< HEAD
2434
マニュアルで Ajax リクエストを送る場合、nonce は各リクエストで毎回送信する必要があります。
2535
送信された nonce は `wp_rest` にセットされたアクションと一緒に利用されます。
2636
API への nonce の受け渡しは、POST のデータや GET のクエリの `_wpnonce` パラメータ、
@@ -32,6 +42,21 @@ Note: Until recently, most software had spotty support for `DELETE` requests. Fo
3242
このクッキー認証が利用できるのは、REST API が WordPress の内部から使われていて、
3343
かつ、ユーザーがログインしている時のみであるということです。
3444
さらに、そのログインユーザーが、実行しようとしているアクションに必要な権限を与えられているということも条件となります。
45+
=======
46+
For developers making manual Ajax requests, the nonce will need to be passed
47+
with each request. The API uses nonces with the action set to `wp_rest`. These
48+
can then be passed to the API via the `_wpnonce` data parameter (either POST
49+
data or in the query for GET requests), or via the `X-WP-Nonce` header.
50+
51+
Note: Until recently, most software had spotty support for `DELETE` requests. For
52+
instance, PHP doesn't transform the request body of a `DELETE` request into a super
53+
global. As such, supplying the nonce as a header is the most reliable approach.
54+
55+
It is important to keep in mind that this authentication method relies on WordPress
56+
cookies. As a result this method is only applicable when the REST API is used inside
57+
of WordPress and the current user is logged in. In addition, the current user must
58+
have the appropriate capability to perform the action being performed.
59+
>>>>>>> upstream/gh-pages
3560
3661
以下は、ビルトインの Javascript クライアントが nonce を生成する例です。
3762

@@ -80,9 +105,14 @@ OAuth 認証でも、ユーザーは通常の WordPress ログイン画面を通
80105
その後、自身に代わって処理を行うクライアントを認証します。
81106
クライアントには、OAuth トークンが発行され、API へのアクセスが許可されます。このアクセス権はユーザー側からいつでも取り消すことができます。
82107

108+
<<<<<<< HEAD
83109
OAuth 認証は、[OAuth 1.0a specification][oauth] (published as
84110
RFC5849) を利用しており、[OAuth plugin][oauth-plugin] がサイトで
85111
有効化されていることが必要です(このプラグインは将来的にコアにマージされます)。
112+
=======
113+
OAuth authentication uses the [OAuth 1.0a specification][oauth] (published as
114+
RFC5849) and requires installing the [OAuth plugin][oauth-plugin] on the site.
115+
>>>>>>> upstream/gh-pages
86116
87117
WP API と OAuth サーバー用のプラグインを有効化したら、コンシューマを作成しましょう。
88118
コンシューマは、アプリケーションの識別子であり、サイトとリンクするために必要な key と secret からなります。
@@ -107,6 +137,7 @@ Secret: LnUdIsyhPFnURkatekRIAUfYV7nmP4iF3AVxkS5PRHPXxgOW
107137
[client-cli]: https://github.com/WP-API/client-cli
108138
[api-console]: https://github.com/WP-API/api-console
109139

140+
<<<<<<< HEAD
110141

111142
ベーシック認証
112143
--------------------
@@ -121,6 +152,32 @@ OAuth 認証は複雑なので、開発段階ではベーシック認証が便
121152
この値は、HTTP Basic 認証の仕様に従い、base64 でエンコードされるべきです。
122153

123154
以下は、ベーシック認証による、WordPress のHTTP API を使った投稿の更新の例です。
155+
=======
156+
Application Passwords or Basic Authentication
157+
---------------------------------------------
158+
Basic authentication is an optional authentication handler for external clients.
159+
Due to the complexity of OAuth authentication, basic authentication can be
160+
useful during development. However, Basic authentication requires passing your
161+
username and password on every request, as well as giving your credentials to
162+
clients, so it is heavily discouraged for production use.
163+
164+
Application passwords are used similarly, however instead of providing your normal
165+
account password, unique and easily revokable passwords are generated from your
166+
edit profile screen in the WordPress admin. These application passwords are valid
167+
exclusively for the REST API and the legacy XML-RPC API and may not be used to log
168+
in to WordPress.
169+
170+
Both basic authentication and application passwords use [HTTP Basic Authentication][http-basic]
171+
(published as RFC2617) and requires installing either the [Basic Auth plugin][basic-auth-plugin] or
172+
[Application Passwords plugin][application-passwords] respectively.
173+
174+
To use Basic authentication, simply pass the username and password with each
175+
request through the `Authorization` header. This value should be encoded (using
176+
base64 encoding) as per the HTTP Basic specification.
177+
178+
This is an example of how to update a post, using these authentications, via the
179+
WordPress HTTP API:
180+
>>>>>>> upstream/gh-pages
124181
125182
```php
126183
$headers = array (
@@ -142,3 +199,4 @@ $response = wp_remote_post( $url, array (
142199

143200
[http-basic]: https://tools.ietf.org/html/rfc2617
144201
[basic-auth-plugin]: https://github.com/WP-API/Basic-Auth
202+
[application-passwords]: https://github.com/georgestephanis/application-passwords

0 commit comments

Comments
 (0)