You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: client_{id,_secret} are no longer passed as query, but basic authentication only (#41)
BREAKING CHANGE: `:client_id` and `:access_token` URL parameters are no longer set by default
BREAKING CHANGE: `client_id` and `client_secret` are now passed as basic authentication for any URL
BREAKING CHANGE: The `url` option has been removed for `auth({ type: "app" })`
BREAKING CHANGE: `auth({ type: "app" })` no longer returns a `.query` key
@@ -339,22 +321,7 @@ The async `auth(options)` method to one of two possible authentication objects
339
321
<code>object</code>
340
322
</th>
341
323
<td>
342
-
<code>{}</code> if no <code>url</code> option was passed or the passed <code>url</code> option <em>does not</em> match <code>/applications/:client_id/tokens/:access_token</code>.<br>
343
-
<br>
344
-
<code>{ authorization }</code> if the passed <code>url</code> option <em>does</em> match <code>/applications/:client_id/tokens/:access_token</code>.
345
-
</td>
346
-
</tr>
347
-
<tr>
348
-
<th>
349
-
<code>query</code>
350
-
</th>
351
-
<th>
352
-
<code>object</code>
353
-
</th>
354
-
<td>
355
-
<code>{ client_id, client_secret }</code> if no <code>url</code> option was passed or the passed <code>url</code> option <em>does not</em> match <code>/applications/:client_id/tokens/:access_token</code>.<br>
356
-
<br>
357
-
<code>{}</code> if the passed <code>url</code> option <em>does</em> match <code>/applications/:client_id/tokens/:access_token</code>.
324
+
<code>{ authorization }</code>.
358
325
</td>
359
326
</tr>
360
327
</tbody>
@@ -433,10 +400,7 @@ The `request` option is an instance of [`@octokit/request`](https://github.com/o
433
400
`auth.hook()` can be called directly to send an authenticated request
Client ID and secret can be passed as URL query parameters (`?client_id=...&client_secret=...`) to get a higher rate limit compared to unauthenticated requests. This is meant for the use on servers only: never expose an OAuth client secret on a client such as a web application!
459
-
460
-
The only exceptions are
420
+
Client ID and secret can be passed as Basic auth in the `Authorization` header in order to get a higher rate limit compared to unauthenticated requests. This is meant for the use on servers only: never expose an OAuth client secret on a client such as a web application!
461
421
462
-
-[`GET /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/oauth_authorizations/#check-an-authorization) - Check an authorization
463
-
-[`POST /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/oauth_authorizations/#reset-an-authorization) - Reset an authorization
464
-
-[`DELETE /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application) - Revoke an authorization for an application
422
+
`auth.hook` will set the correct authentication header automatically based on the request URL. For all [OAuth Application endpoints](https://developer.github.com/v3/apps/oauth_applications/), the `Authorization` header is set to basic auth. For all other endpoints and token is retrieved and used in the `Authorization` header. The token is cached and used for succeeding requsets.
465
423
466
-
For these endpoints, client ID and secret need to be passed as basic authentication in the `Authorization` header. Because of these exception an `options.url` parameter must be passed to the async `auth()` function if `options.type` is set to `oauth-app`. Additionally, `:client_id` and `:access_token` are defaulted to `options.clientId` passed to `createOAuthAppAuth(options)` and the token which was created using `options.code`, if passed.
467
-
468
-
To reset the current access token, you can do this
The internally cached token will be replaced and used for succeeding requests. See also ["the REST API documentation"](https://developer.github.com/v3/oauth_authorizations/).
Copy file name to clipboardexpand all lines: src/requires-basic-auth.ts
+3-4
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
/**
2
-
* An OAuth app authenticates using ?client_id=...&client_secret=... query parameters, with the
3
-
* exception of these three endpoints, which require the client ID/secret to be sent as basic auth
2
+
* The following endpoints require an OAuth App to authenticate using its client_id and client_secret.
4
3
*
5
4
* - [`POST /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#check-a-token) - Check a token
6
5
* - [`PATCH /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Reset a token
@@ -14,8 +13,8 @@
14
13
* - [`DELETE /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#revoke-an-authorization-for-an-application) - Revoke an authorization for an application
15
14
* - [`DELETE /applications/:client_id/grants/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#revoke-a-grant-for-an-application) - Revoke a grant for an application
0 commit comments