This is a Node.js Express sample application that demonstrates the complete OAuth2 flow for Orbitar.
This sample demonstrates:
- Authorization code flow
- Token exchange
- API requests with access tokens
- Token refresh
- Embedded app card landing page simulation
- Node.js 14+
- npm packages: express, express-session, axios
-
Install dependencies:
npm install
-
Edit the configuration section in
index.jsto add your client credentials:const config = { clientId: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET', // other config... };
-
Run the application:
npm start
-
Access the application at http://localhost:3000
The sample uses the following configuration structure:
const config = {
// Replace with your client credentials
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
// Application settings
port: 3000,
scope: 'status',
redirectUri: 'http://localhost:3000/callback',
// This would be your Initial Authorization URL in the client app settings
initialAuthUrl: 'http://localhost:3000/start',
// Orbitar endpoints
authorizationEndpoint: 'https://orbitar.space/oauth2/authorize',
tokenEndpoint: 'https://api.orbitar.space/api/v1/oauth2/token',
apiEndpoint: 'https://api.orbitar.space/api/v1/status'
};This sample disables SSL certificate verification for ease of development. This is NOT suitable for production. In a production environment:
- Ensure proper SSL certificate validation
- Store client secrets securely
- Use HTTPS for all communication
- Implement proper state validation and CSRF protection
- Use secure, randomly generated session keys