ttauth-api
v1.0.0
Published
Makes it easy to connect to TTAuth.
Downloads
3
Readme
TTAuth API Documentation
This module simplifies the usage of the TTAuth login page. It provides two main functions: redirect and get.
Functions
redirect(res, redirectURI)
Version added: 1.0.0
Redirects the user to TTAuth.
Usage:
redirect(res, "https://example.com/ttauth"); // Returns all data to the specified URIParameters:
- res: (Required) The response object (res) from an Express instance.
- redirectURI: (Required) A string containing the HTTP(s) request to send back to the server.
Notes:
- The function uses res.redirect() for the redirection.
get(query, email, birth)
Version added: 1.0.0
Extracts and returns data from a TTAuth request.
Usage:
get(req.query, true, false); // Returns username, password, and email.Parameters:
- query: (Required) The request object (req.query) from an Express instance.
- email: (Optional) Boolean indicating whether the email should be included in the response.
- birth: (Optional) Boolean indicating whether the birth date should be included in the response.
Returns:
An object containing the following fields:
- username: The username.
- password: The password.
- email: (If email is set to true) The email address.
- birth: (Currently non-functional) The birth date, if enabled.
Notes:
- The birth field is currently non-functional.
Example Usage
const ttauth = require('./ttauth');
// Redirect to the TTAuth page
ttauth.redirect(res, "https://example.com/callback");
// Retrieve user data
const userData = ttauth.get(req.query, true, false);
console.log(userData);Exports
The module exports the following functions:
- redirect
- get
