GDPlatform OAuth SDK
Official JavaScript SDK for secure Geometry Dash authentication.
GitHub: GDPlatform/GD-OAuth
Introduction
This SDK provides helper functions to generate OAuth URLs and validate
authorization codes using GDPlatform's API.
CDN Setup
Include the SDK directly from jsDelivr:
<script src="https://cdn.jsdelivr.net/gh/GDPlatform/OAuth-API@main/bin/api.js"></script>
⚠ For production use, replace
@main with a version tag.
OAuth Flow Overview
1. Generate OAuth URL
2. Redirect user to GDPlatform
3. Receive
4. Validate code via API
2. Redirect user to GDPlatform
3. Receive
?code=auth_xxx4. Validate code via API
generateUrlOAuth()
Function
Generates the redirect URL to start authentication.
const url = generateUrlOAuth(
"YOUR_CLIENT_ID",
"https://yourapp.com/callback",
"account_id,profile"
);
window.location.href = url;
- clientId — Your application ID
- redirectURI — Callback URL
- scopes — Comma-separated permissions
validateOAuthCode()
Async
Exchanges the authorization code for user data.
const user = await validateOAuthCode(
"auth_xyz",
["account_id", "profile"]
);
console.log(user);
- code — Authorization code from redirect
- scopes — Array of requested permissions
- Returns: User object
Full Example
// Step 1: Redirect user
const login = () => {
const url = generateUrlOAuth(
"YOUR_CLIENT_ID",
"https://yourapp.com/callback",
"account_id,profile"
);
window.location.href = url;
};
// Step 2: After redirect
const params = new URLSearchParams(window.location.search);
const code = params.get("code");
if (code) {
validateOAuthCode(code, ["account_id", "profile"])
.then(data => console.log("User:", data))
.catch(err => console.error(err));
}