Skip to main content

Get authenticated user with client credentials

This example demonstrates how to get the authenticated user using the client credentials flow with different libraries and languages.

How it works

  • The application sends a request to obtain an access token using its client ID and client secret.
  • Once the token is received, it is included in the request headers for authentication.
  • The API responds with the authenticated user data.

Examples

import axios from 'axios';

const clientId = 'YOUR_CLIENT_ID';
const clientSecret = 'YOUR_CLIENT_SECRET';

axios.post('https://miwa.lol/api/oauth2/token', {
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
}).then((response) => {
const accessToken = response.data.access_token;

axios.get('https://miwa.lol/api/user', {
headers: { Authorization: `Bearer ${accessToken}` },
}).then((response) => {
console.log(response.data);
});
});