-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from AdguardTeam/add-dns-api-version-1-8
Add DNS API version 1.8 (authorization endpoint)
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,45 @@ $ curl 'https://api.adguard-dns.com/oapi/v1/revoke_token' -i -X POST \ | |
|:----------------- |:-------------------------------------- | | ||
| **refresh_token** | `REFRESH TOKEN` which is to be revoked | | ||
|
||
### Authorization endpoint | ||
|
||
> To access this endpoint, you need to contact us at **[email protected]**. | ||
> Please describe the reason and use cases for this endpoint, as well as provide the redirect URI. | ||
> Upon approval, you will receive a unique client identifier, which should be used for the **client_id** parameter. | ||
The **/oapi/v1/oauth_authorize** endpoint is used to interact with the resource owner and get the authorization to access the protected resource. | ||
|
||
The service redirects you to AdGuard to authenticate (if you are not already logged in) and then back to your application. | ||
|
||
The request parameters of the **/oapi/v1/oauth_authorize** endpoint are: | ||
|
||
| Parameter | Description | | ||
|:------------------|:------------------------| | ||
| **response_type** | Tells the authorization server which grant to execute | | ||
| **client_id** | The ID of the OAuth client that asks for authorization | | ||
| **redirect_uri** | Contains a URL. A successful response from this endpoint results in a redirect to this URL | | ||
| **state** | An opaque value used for security purposes. If this request parameter is set in the request, it is returned to the application as part of the **redirect_uri** | | ||
| **aid** | Affiliate identifier | | ||
|
||
For example: | ||
|
||
```http request | ||
https://api.adguard-dns.io/oapi/v1/oauth_authorize?response_type=token&client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&state=1jbmuc0m9WTr1T6dOO82 | ||
``` | ||
|
||
To inform the authorization server which grant type to use, the **response_type** request parameter is used as follows: | ||
|
||
- For the Implicit grant, use **response_type=token** to include an access token. | ||
|
||
A successful response is **302 Found**, which triggers a redirect to **redirect_uri** (which is a request parameter). The response parameters are embedded in the fragment component (the part after `#`) of the **redirect_uri** parameter in the **Location** header. | ||
|
||
For example: | ||
|
||
```http request | ||
HTTP/1.1 302 Found | ||
Location: REDIRECT_URI#access_token=...&token_type=Bearer&expires_in=3600&state=1jbmuc0m9WTr1T6dOO82 | ||
``` | ||
|
||
### Accessing API | ||
|
||
Once the access and the refresh tokens are generated, API calls can be made by passing the access token in the header. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters