Registering Your Application
Before using OAuth2, you need to register your application:Access Developer Settings
Go to your Speckle Server → Avatar → Settings → Profile → Developer → Apps
Create New App
Click “New App” and provide: - App Name: Display name for your
application - Redirect URIs: Valid redirect URIs (e.g.,
https://yourapp.com/callback) - Scopes: Permissions your app needsRedirect URIs: Must match exactly. For development, you can use
http://localhost:3000/callback. For production, use your actual domain.Managing App Permissions
Once registered, your application can request specific scopes that define the level of access to user data. Users can review and revoke these permissions at any time through their account settings. Common Scopes:| Scope | Description | Use Case |
|---|---|---|
streams:read | Read project data | View-only applications |
streams:write | Create and modify projects | Data management apps |
profile:read | Read user profile | Display user information |
profile:email | Access user email | User identification |
Users can review and revoke app permissions at any time: Avatar → Settings →
Profile → Developer → Authorized Apps
Updating App Settings
You can update your app’s settings at any time:- Redirect URIs: Add or modify allowed redirect URIs
- Scopes: Update requested permissions (requires re-authorization)
- App Name: Change the display name
- Revoke Access: Users can revoke access to your app
Getting a token through PKCE
PKCE (Proof Key for Code Exchange) is an extension to the OAuth2 Authorization Code flow that provides enhanced security for public clients, such as single-page applications (SPAs) and mobile apps. It prevents authorization code interception attacks by requiring the client to generate a unique code verifier and challenge during the authentication process. Best for: Multi-user web applications, public-facing apps, third-party integrationsAt the moment Speckle only supports PKCE for browser-based applications. If you’re building a server-side application reach out to us on the Speckle Community Forum.
Implementing OAuth2 with PKCE
The whole flow consists of the following steps:- Generate Code Verifier & Challenge: Your website generates a random code verifier and its SHA256 hash (code challenge)
- Redirect to Authorization: User is redirected to Speckle’s authorization endpoint
- User Authorizes: User logs in and grants permissions to your app
- Receive Authorization Code: Speckle redirects back with an authorization code
- Exchange for Token: Your app exchanges the code + verifier for an access token
/oauth/token endpoint, which enforces full RFC 7636 PKCE: the server stores the codeChallenge (BASE64URL(SHA256(codeVerifier))) during authorization and verifies the raw codeVerifier on token exchange.
Generate the PKCE Code Verifier and Code Challenge
Generate a cryptographically random
codeVerifier, then derive the
codeChallenge from it using SHA-256 and base64url encoding (RFC 7636 §4.1–4.2).
Store the codeVerifier in sessionStorage — it is needed again after the
redirect.Redirect to Speckle's Authorization Endpoint
Build the authorization URL using the After the user authenticates, Speckle redirects them to the
codeChallenge as the path parameter
and include code_challenge_method=S256 so the server knows to hash-verify
it. Persist the codeVerifier before navigating away.redirectUrl that is registered
during the application registration with an access_code query parameter appended.Read the Authorization Code from the Callback URL
On the page your
redirectUrl points to, extract the access_code that
Speckle appended.Exchange the Authorization Code for an Access Token
POST to
/oauth/token with the accessCode and the original codeVerifier.
The server computes SHA256(codeVerifier) and compares it to the stored
codeChallenge — if they match, tokens are issued.Store the Token and Clean Up
Persist the token for future API calls and remove the one-time
codeVerifier
from storage.For complete OAuth2 implementation examples, see the Building Custom Apps
guide.