This is a C++ authentication SDK for desktop and Windows applications that want simple integration with the AuthlyX API.
This folder is primarily for SDK users. The sample project here is only a reference example to help you integrate faster.
The C++ SDK supports:
- Header-only
- Static library
- DLL
All three use the same codebase and the same SDK behavior.
AuthlyX-CPP-Example/
|- include/
| \- AuthlyX.h
|- src/
| \- AuthlyX.cpp
|- builds/
| |- MSVC/
| | |- x86/
| | \- x64/
| \- MinGW/
| |- x86/
| \- x64/
\- AuthlyX.h
include/AuthlyX.his the real SDK header.src/AuthlyX.cppis the thin source wrapper used to build the precompiled library and DLL tiers.AuthlyX.his the simple include developers can drop into their project.
AuthlyX AuthlyXApp(
"12345678",
"MYAPP",
"1.0.0",
"wLZchZYsGanxViAudtYWWQFIQVomt2O3R6wkihR3B"
);
/*
Optional:
- Set debug to false to disable SDK logs.
- Set api to your custom domain, for example: https://example.com/api/v2
*/Then initialize:
AuthlyXApp.Init();AuthlyX AuthlyXApp(
"12345678",
"MYAPP",
"1.0.0",
"wLZchZYsGanxViAudtYWWQFIQVomt2O3R6wkihR3B",
false,
"https://example.com/api/v2"
);-
debugtrueby default- set to
falseto disable SDK logs
-
api- defaults to
https://authly.cc/api/v2 - set it if you use a custom domain
- defaults to
Init()Login(identifier, password = "", deviceType = "")Register(username, password, licenseKey, email = "")ExtendTime(username, licenseKey)GetVariable(key)SetVariable(key, value)Log(message)GetChats(channelName)SendChat(message, channelName = "")ValidateSession()
// Username + password
AuthlyXApp.Login("username", "password");
// License key only
AuthlyXApp.Login("XXXXX-XXXXX-XXXXX-XXXXX-XXXXX");
// Device login
AuthlyXApp.Login("YOUR_MOTHERBOARD_ID", "", "motherboard");The SDK routes Login(...) automatically:
identifier + passwordfor username loginidentifier onlyfor license logindeviceType + identifierfor device login
AuthlyXApp.Login("username", "password");
if (AuthlyXApp.response.success)
{
std::cout << "Login success" << std::endl;
std::cout << AuthlyXApp.userData.username << std::endl;
std::cout << AuthlyXApp.userData.subscriptionLevel << std::endl;
}
else
{
std::cout << AuthlyXApp.response.message << std::endl;
}userData.subscriptionLevel is populated automatically after username, license, and device authentication flows.
AuthlyXApp.Login("XXXXX-XXXXX-XXXXX-XXXXX-XXXXX");
if (AuthlyXApp.response.success)
{
std::cout << "License login success" << std::endl;
}
else
{
std::cout << AuthlyXApp.response.message << std::endl;
}AuthlyXApp.Login("YOUR_MOTHERBOARD_ID", "", "motherboard");
if (AuthlyXApp.response.success)
{
std::cout << "Motherboard login success" << std::endl;
}
else
{
std::cout << AuthlyXApp.response.message << std::endl;
}AuthlyXApp.Login("YOUR_PROCESSOR_ID", "", "processor");
if (AuthlyXApp.response.success)
{
std::cout << "Processor login success" << std::endl;
}
else
{
std::cout << AuthlyXApp.response.message << std::endl;
}AuthlyXApp.SetVariable("theme", "dark");
std::string value = AuthlyXApp.GetVariable("theme");
std::cout << value << std::endl;AuthlyXApp.SendChat("Hello world", "MAIN");
std::string chats = AuthlyXApp.GetChats("MAIN");
std::cout << chats << std::endl;By default, SDK logging is enabled.
Logs are written to:
C:\ProgramData\AuthlyX\{AppName}\YYYY_MM_DD.log
To disable logs:
AuthlyX AuthlyXApp(
"12345678",
"MYAPP",
"1.0.0",
"wLZchZYsGanxViAudtYWWQFIQVomt2O3R6wkihR3B",
false
);Sensitive values such as passwords, secrets, signatures, request IDs, nonces, session IDs, license keys, and hashes are masked automatically.
Include the header and compile your project normally.
#include "AuthlyX.h"Use this when you want the fastest setup with no separate linking step.
Include the header and link the matching static library for your compiler family:
- MSVC:
builds/MSVC/x86/AuthlyX.libbuilds/MSVC/x64/AuthlyX.lib
- MinGW:
builds/MinGW/x86/libAuthlyX.abuilds/MinGW/x64/libAuthlyX.a
Include the header and ship the matching DLL:
- MSVC:
builds/MSVC/x86/AuthlyX.dllbuilds/MSVC/x64/AuthlyX.dll
- MinGW:
builds/MinGW/x86/AuthlyX.dllbuilds/MinGW/x64/AuthlyX.dll
They only need:
- the header
- their normal Windows C++ compiler
They do not need the prebuilt lib or dll.
They need:
- the header
- the matching static library for their compiler family
They do not need both MSVC and MinGW installed. They only need the toolchain they already build their project with.
They need:
- the header
- the matching DLL
- the same compiler family for their project
Runtime notes:
- MSVC DLL builds depend on the Microsoft Visual C++ runtime
- MinGW DLL builds depend on MinGW runtime DLLs such as
libstdc++-6.dlland the matchinglibgcchelper DLL
Current observed DLL runtime dependencies:
- MSVC x64:
MSVCP140.dllVCRUNTIME140.dllVCRUNTIME140_1.dll
- MinGW x64:
libstdc++-6.dlllibgcc_s_seh-1.dll
- MinGW x86:
libstdc++-6.dlllibgcc_s_dw2-1.dll
So consumers do not need to install the opposite compiler toolchain, but DLL users do need the correct runtime available.
The SDK also exposes a flat C API for C projects.
Main C entry points:
AuthlyX_CreateAuthlyX_InitAuthlyX_LoginAuthlyX_AuthenticateAuthlyX_GetMessageAuthlyX_GetUsernameAuthlyX_GetLicenseKeyAuthlyX_Destroy
Example:
#include "AuthlyX.h"
#include <stdio.h>
int main(void) {
void* sdk = AuthlyX_Create("12345678", "MYAPP", "1.0.0", "your-secret");
if (!AuthlyX_Init(sdk)) {
printf("%s\n", AuthlyX_GetMessage(sdk));
AuthlyX_Destroy(sdk);
return 1;
}
if (!AuthlyX_Login(sdk, "username", "password")) {
printf("%s\n", AuthlyX_GetMessage(sdk));
}
AuthlyX_Destroy(sdk);
return 0;
}If you change include/AuthlyX.h:
- header-only users do not need a rebuild
- prebuilt static libs and DLLs should be rebuilt
Run:
.\builds\MSVC\build.ps1
.\builds\MinGW\build.ps1If you only care about one compiler family, run only that script.
- Use the root
AuthlyX.hfor the simplest include path. - Do not mix MSVC binaries with MinGW projects.
- Do not mix MinGW binaries with MSVC projects.
- The sample project in this folder is only a reference integration.