OAuth URLs
| URL | Description |
|---|---|
https://metafy.gg/auth/authorize | Authorize URL |
https://metafy.gg/irk/oauth/token | Token URL |
https://metafy.gg/irk/oauth/revoke | Token Revocation URL |
Setting up OAuth
1
Create your OAuth Application
Go to your OAuth Applications settings and create a new application.Retrieve your
client_id and client_secret from the application settings.2
Read the documentation
Familiarize yourself with the OAuth flow you want to use.
3
???
Let us know what you end up building!
State and Security
Cross-site request forgery (CSRF) and Clickjacking attacks are common security vulnerabilities in web applications. Thestate parameter is a security feature that helps prevent these attacks by adding a unique token to the OAuth2 flow.
When the user is redirected back to your application, you should verify that the state parameter matches the value you provided in the initial request.
While Metafy does not require the use of the state parameter, we recommend using it.
Authorization Code Grant
The authorization code grant is what most developers will recognize as “standard” and involves retrieving an authorization code and exchanging it for an access token. It allows the authorization server to act as an intermediary between the client and the resource owner, so the resource owner’s credentials are never exposed to the client.Authorization URL Example
client_id is your OAuth application’s client id. scope is a list of scopes separated by url encoded spaces (%20). redirect_uri is the URL
you provided when creating your OAuth application, url-encoded. state is the unique string mentioned in State and Security.
When someone navigates to this URL, they will be prompted to authorize your application for the requested scoeps. On acceptance, they will be redirected to your
redirect_uri, which will contain an additional query parameter code that you can exchange for an access token. state will also be returned if you included
it in your original request and should be validated at this point.
Redirect URL Example
code is now exchanged for the account’s access token by making a POST request to the token URL with the following parameters:
grant_type- must be set toauthorization_codecode- the authorization code provided to your redirectredirect_uri- The URL you provided when creating your OAuth applicationclient_id- your oauth application’sclient_idclient_secret- your oauth application’sclient_secret
Access Token Exchange Example
Access Token Response
expires_in is how long, in seconds, until the returned access token expires, allowing you to anticipate the expiration and refresh the token. To refresh, make
another POST request to the token URL with the following parameters:
grant_type- must be set torefresh_tokenrefresh_token- the refresh token provided in the access token responseclient_id- your oauth application’sclient_idclient_secret- your oauth application’sclient_secret
Token Revocation
To disable an access or refresh token, you can revoke it by making aPOST request to the token revocation URL with the following parameters:
token- the access or refresh token to revoketoken_type_hint(optional) - set toaccess_tokenorrefresh_tokenclient_id- your oauth application’sclient_idclient_secret- your oauth application’sclient_secret
Client Credentials Grant
The client credentials flow is a quick and easy way for developers to get their own access tokens. By making aPOST request to the token URL with
a grant type of client_credentials, you will be returned an access token for the application owner.
You can specify scopes with the scope parameter.
Client Credentials Access Token Response
Notice, that you do not get a
refresh_token when using the client credentials flow.