-
Notifications
You must be signed in to change notification settings - Fork 27
User Authentication
We authenticate users via a simple email verification flow - which is used to generate OAuth 2 access tokens. A user can manage the tokens they have been issued via their OAuth 2 token page.
Authentication occurs by asking for their email and then for the 5-digit security code sent to their email. To do so, first call emailRequest to send the email and then emailExchange to exchange the security code for an access token that will be handled internally by the SDK so you won't need to deal with it.
void Instance::emailRequest(const std::string& email, const std::function<void(const modio::Response&, const std::string&)>& callback)
API endpoint used: Email Request
Requests a 5-digit security code to be sent via email. emailExchange should be called after to complete the authentication process.
Name | Type | Description |
---|---|---|
const std::string& |
User's email. | |
callback | const std::function<void(const modio::Response&, const std::string&)>& |
Function called once the process finished. |
Name | Type | Description |
---|---|---|
response | const modio::Response& |
modio::Response object that contains the mod.io response status. |
modio_instance.emailRequest("example@mail.com", [&](const modio::Response& response)
{
if (response.code == 200)
{
//Authentication code successfully requested
}
});
void Instance::emailExchange(const std::string& security_code, const std::function<void(const modio::Response&)>& callback)
API endpoint used: Email Exchange
Exchanges the 5-digit code for an authentication token. The token is handled internally by the SDK.
Name | Type | Description |
---|---|---|
security_code | const std::string& |
5-digit code sent to users via email when emailRequest was called. |
callback | const std::function<void(const modio::Response&)>& |
Function called once the process finished. |
Name | Type | Description |
---|---|---|
response | const modio::Response& |
modio::Response object that contains the mod.io response status. |
modio_instance.emailExchange("50AD4", [&](const modio::Response& response)
{
if (response.code == 200)
{
//Email exchanged successfully
}
});
void Instance::authenticateViaToken(const std::string &access_token);
Authenticates the user by providing a valid mod.io token directly.
Name | Type | Description |
---|---|---|
access_token | const std::string& |
mod.io user authentication token. |
modio_instance.authenticateViaToken("eykger...lkw421");
Returns true if the user is logged in, otherwise returns false.
bool Instance::isLoggedIn()
Returns a modio::User object corresponding to the current user logged in.
modio::User Instance::getCurrentUser()
if(modio_instance.isLoggedIn())
{
std::cout << "Logged in as " << modio_instance.getCurrentUser().username << std::endl;
}else
{
std::cout << "You are not logged in." << std::endl;
}
Logs out the user from mod.io.
void Instance::logout()
- Home
- Table of Contents
- Getting Started
- SDK Methods
- Creators
- Editors
- Schemas
- modio::Avatar
- modio::Comment
- modio::Dependency
- modio::Download
- modio::Error
- modio::Filehash
- modio::Game
- modio::GameTagOption
- modio::Header
- modio::Icon
- modio::Image
- modio::InstalledMod
- modio::Logo
- modio::Media
- modio::MetadataKVP
- modio::Mod
- modio::ModEvent
- modio::Modfile
- modio::QueuedModDownload
- modio::QueuedModfileUpload
- modio::Rating
- modio::Response
- modio::Stats
- modio::Tag
- modio::User
- Debugging
- Constants
-
C Compatibility
- Methods
- Initialization, Process and Shutdown (C compatible)
- User Authentication (C compatible)
- Mods (C compatible)
- Modfiles (C compatible)
- Media (C compatible)
- Subscriptions (C compatible)
- Events (C compatible)
- Stats (C compatible)
- Tags (C compatible)
- Ratings (C compatible)
- Metadata KVP (C compatible)
- Dependencies (C compatible)
- Comments (C compatible)
- Reports (C compatible)
- Me (C compatible)
- Downloads (C compatible)
- Uploads (C compatible)
- Logs (C compatible)
- External Auth (C compatible)
- Configuration (C compatible)
- Creators
- Editors
- Schemas
- ModioAvatar
- ModioComment
- ModioDependency
- ModioDownload
- ModioError
- ModioFilehash
- ModioGame
- ModioGameTagOption
- ModioHeader
- ModioIcon
- ModioImage
- ModioInstalledMod
- ModioListNode
- ModioLogo
- ModioMedia
- ModioMetadataKVP
- ModioMod
- ModioModEvent
- ModioModfile
- ModioQueuedModDownload
- ModioQueuedModfileUpload
- ModioRating
- ModioResponse
- ModioStats
- ModioTag
- ModioUser
- Methods
- Building