Skip to main content

OAuth Integration Guide

This document provides a complete third-party app integration guide to help you integrate the NodeLoc OAuth Provider into your application.

📋 Table of contents

🚀 Quick start

1. Create an OAuth app

Visit the NodeLoc forum and create an OAuth app (requires Gold member TL2 or above):
OAuth app management page
Record the following information:
  • Client ID: the unique identifier of your app
  • Client Secret: the app secret (shown only once — store it safely)
  • Redirect URI: the callback URL after authorization
If the app requests the email scope, it must be reviewed by an admin before it can be used.

2. Configure environment variables

3. Start integrating

Choose your development language and refer to the integration examples below to get started quickly.

🔐 OAuth 2.0 authorization flow

Flow diagram

Detailed steps

Step 1: Redirect to the authorization page

Redirect the user to the following URL:
Parameter description: Available scopes: Notes:
  • If the app requests the email scope, it must be reviewed by an admin before it can be used
  • The review status can be viewed on the app management page
  • Apps that have not passed review cannot complete the authorization flow

Step 2: Receive the authorization code

After the user authorizes, NodeLoc redirects back to your redirect_uri with an authorization code: Authorization successful:
User denied authorization:
Error parameter description: Handling recommendations:
  • Check for the presence of an error parameter to determine whether authorization succeeded
  • If the user denies authorization, prompt them in a friendly way and offer an option to authorize again
  • Log denial events to analyze user behavior
Example code (Node.js):
Security tip: Verify that the state parameter matches the one sent in step 1.

Step 3: Exchange for an Access Token

Exchange the authorization code for an Access Token:
Example response:

Step 4: Get user info

Use the Access Token to get user info:
Example response:
Field description:

🔌 API endpoints

Authorization endpoint

Used to initiate an authorization request; the user visits this endpoint in a browser.

Token endpoint

Used to exchange an authorization code for an Access Token, or to refresh an access token with a Refresh Token. Supported grant types:
  • authorization_code - authorization code flow
  • refresh_token - refresh token (if supported)

UserInfo endpoint

Use an Access Token to get the currently authorized user’s info. Request header:

OIDC Discovery endpoint (optional)

Returns OIDC configuration information, supporting auto-discovery.

💻 Integration examples

Node.js + Express

Install dependencies

Full example code

Environment variable configuration

Create a .env file:

Run the app

Visit http://your-url.com to see the login page.

Python + Flask

Install dependencies

Full example code

Run the app


Ruby on Rails + Devise

Gemfile

config/initializers/devise.rb

app/models/user.rb

app/controllers/users/omniauth_callbacks_controller.rb


❓ FAQ

1. How do I handle token expiry?

Access Tokens are valid for 2 hours (7200 seconds) by default. After expiry, the user must authorize again, or use a Refresh Token (if supported).

2. How do I handle errors?

All errors are returned in the standard OAuth 2.0 error format:
Common error codes:

3. What if the name field is empty?

When a user hasn’t set a display name, the name field automatically falls back to the username value. No extra handling is needed.

4. How do I test the OAuth integration?

Use the following test script for quick verification:

5. Which scopes are supported?

The following scopes are currently supported:
  • openid - standard OpenID Connect scope (required, cannot be removed)
  • profile - user profile (avatar, bio, etc.)
  • email - user email address (requires admin review)
Example:
Important:
  • The openid scope is required; it is automatically included when creating an app and cannot be removed
  • If your app requests the email scope, it must be reviewed and approved by an admin after creation before it works properly.

6. App review status explained

When your app requests a scope that requires review (such as email), it will be in one of the following states: How to check the review status:
  1. Visit https://www.nodeloc.com/oauth-provider/applications
  2. Check the “Review status” column in the app list
  3. Pending apps show a yellow warning icon
Handling a rejected review:
  • Contact a NodeLoc admin to learn the reason for rejection
  • If you don’t need the email scope, edit the app and remove it
  • If the modified app no longer includes scopes that require review, it automatically becomes “Approved”

7. How do I protect the Client Secret?

Important security tips:
  • ✅ Server-side storage: store the Client Secret in server-side environment variables
  • ✅ HTTPS communication: production environments must use HTTPS
  • ✅ Rotate regularly: regenerate the Client Secret in NodeLoc periodically
  • ❌ Don’t expose it: never commit the Secret to version control or front-end code
  • ❌ Don’t log it: never log the full Secret

8. Production deployment checklist

Before deploying, confirm the following:
  • Use HTTPS
  • Configure the correct Redirect URI
  • Store environment variables securely
  • Implement error handling and logging
  • Add a State parameter to prevent CSRF
  • Implement a token refresh mechanism
  • Configure session timeouts
  • Add a user logout feature
  • Test the complete authorization flow