Flows
To keep track of your installed installed servers, you need to implement a callback which can securely verify any OAuth2 requests.
sequenceDiagram
participant User
participant OAuth
participant Server
User->>OAuth: Authorizes application grant
OAuth->>User: Sends status response
User->>Server: Redirect with Verification code
Server-->>OAuth: Verify
Note right of Server: Be sure to validate the response <br/>from the OAuth request.
Server->>User: Redirect back to UI
Authorize
POST
https://miki.bot/oauth2/authorize
Path to the OAuth2 authorization UI.
Query Parameters
Parameter | Type | Note |
---|---|---|
client_id | Snowflake | This can be found in your application page on the developer application page. |
redirect_uri | string | Can only be any of the predetermined redirect URIs defined in your application. |
scope | string | Array of scopes joined by a space. e.g. first.scope%20second.scope |
guild_id? | Snowflake | Correlates with a Discord Guild ID. |
Verify
Request
POST
https://api.miki.bot/oauth2/verify
API route used to verify your redirected token data.
Query Parameters
Parameter | Type | Note |
---|---|---|
client_id | Snowflake | This can be found in your application page on the developer application page. |
code | string | An additional authentication token that you receive from the redirect payload. |
Response Structure
authorized: boolean;
guild: {
/**
* Correlates directly with the Discord Guild ID
*/
id: Snowflake;
name: string;
/**
* Contains the full URL to the avatar.
*/
avatarUrl: string;
}
Handle integration revokes
In the event of a server removing your integration through the dashboard, you'll no longer be able to send any requests for that guild. Due to the nature of OAuth2, there's no direct way to propagate a removal request to an OAuth consumer. What we recommend doing is listen for a 403 (forbidden), and whenever it happens, remove it from your own stored profile.
flowchart TD
subgraph Z[" "]
direction LR
A[Your App] --> B(Miki API)
B --> C{Request Status?}
C -->|403| E[delete integration]
C -->|200| F[all good!]
end