Table of Contents
auth
The auth table type contains information about an auth token. It follows a format similar to the token response body endpoint in the OAuth2 specification1), though the refresh_token
field will never be included.
This type is used as the return value for getAuthToken()
in both the satori and koishi globals and can be used to make HTTP requests to Flashii API endpoints on behalf of the either bot.
access_token
The access_token field contains the access token string, used for the second part of a HTTP Authorization header.
token_type
The token_type field contains the type string of the token, used for the first part of a HTTP Authorization header.
While the value of this field is likely always to be the string Bearer
, you should still use this field in your format string in case there are any changes to this in the future.
expires_in
The optional expires_in field contains an integer indicating how many seconds this token has left to live before it must be renewed using the refresh_token. This process is handled by the Komeiji runtime, which is why the refresh_token field is always omitted.
scope
The optional scope field contains the scope string for the access_token if it differed from the scope the Komeiji runtime requested with the authorization server.
Example
This example sends a HTTP request to an arbitrary endpoint using Satori's access token.
local http = require('kmj-http') local auth = satori.getAuthToken() local result = http.get('https://flashii.net/api/v1/beans', { timeout = 5000, type = 'json', requestHeaders = { ['Authorization'] = string.format('%s %s', auth.token_type, auth.access_token) } })