Add a single-page application (SPA)
Add a single-page application to enable user authentication through SecureAuth.
Before you begin
You'll need:
- Access to your workspace in SecureAuth
- The redirect URI where users should land after logging in (your application's callback URL)
Add the application
-
In your workspace, select Applications > Clients > Create client.
-
Enter a name for your application, select the Single Page type, and click Create.

-
Configure the Redirect URI for your application.
The redirect URI is the URL where SecureAuth sends users after they log in. This must match the callback URL configured in your application code.

-
Copy the Client ID and save the configuration.
You'll need the Client ID to connect your application code to SecureAuth.

Integrate with your application
After creating the client in SecureAuth, integrate it with your application code using an OAuth/OIDC library.
Example: React.js with cloudentity-auth-js
// Install dependencies: yarn add @cloudentity/auth
import CloudentityAuth from '@cloudentity/auth';
import {useEffect, useState} from "react";
// Initialize authentication
const cloudentity = new CloudentityAuth({
responseType: ['code'],
domain: 'your-tenant.region.connect.secureauth.com',
tenantId: 'your-tenant',
authorizationServerId: 'your-workspace',
clientId: 'paste-your-client-id-here',
redirectUri: "http://localhost:3000/",
userInfoUri: 'https://your-tenant.region.connect.secureauth.com/your-tenant/your-workspace/userinfo',
scopes: ['profile', 'email', 'openid']
});
function App() {
const [user, setUser] = useState({})
useEffect( () => {
cloudentity.getAuth().then(
function (authResponse) {
console.log('User authenticated', authResponse);
cloudentity.userInfo().then(function (userinfoResponse) {
setUser(userinfoResponse);
})
},
function (errorResponse) {
console.log('Authentication required', errorResponse);
cloudentity.authorize();
}
);
}, [])
return (
<div>
<h1>Hello {user.name}!</h1>
</div>
);
}
export default App;
Example: Vue.js with cloudentity-auth-js
// Install dependencies: yarn add @cloudentity/auth
import CloudentityAuth from '@cloudentity/auth'
const cloudentity = new CloudentityAuth({
responseType: ['code'],
domain: 'your-tenant.region.connect.secureauth.com',
tenantId: 'your-tenant',
authorizationServerId: 'your-workspace',
clientId: 'paste-your-client-id-here',
redirectUri: "http://localhost:5173/",
userInfoUri: 'https://your-tenant.region.connect.secureauth.com/your-tenant/your-workspace/userinfo',
scopes: ['profile', 'email', 'openid']
});
router.beforeEach((to, from, next) => {
cloudentity.getAuth().then(
function (authResponse) {
console.log('User authenticated', authResponse);
cloudentity.userInfo().then(function (userinfoResponse) {
next();
})
},
function (errorResponse) {
console.log('Authentication required', errorResponse);
cloudentity.authorize();
}
);
})
You can use any OAuth/OIDC library that supports the Authorization Code flow with PKCE.
Test the integration
- Start your application.
- Navigate to the login page.
- Verify that users are redirected to SecureAuth for authentication.
- After logging in, confirm users are redirected back to your application.
Next steps
- Restrict access with user policies to control who can use the application
- Set up single sign-on (SSO) by connecting external identity providers
- Skip the consent screen for your own applications
- Enable passwordless authentication for a better user experience