chatgpt-4o-latest-20250326· OpenAI
LMArena Human Preference 140K
I am using the nodejs npm library oauth2-mock-server. The examples show how to emit an…
- User
I am using the nodejs npm library oauth2-mock-server. The examples show how to emit an error into the userinfo endpoint once. How could I override the default response so it always returns my userinfo json.
- Assistant
To override the default behavior of the
userinfoendpoint in theoauth2-mock-serverso it always returns your custom JSON, you can use thesetUserInfomethod, which sets the userinfo response that is returned by default.Here’s how you can do that:
✅ Example: Always return custom userinfo
jsconst { OAuth2Server } = require('oauth2-mock-server'); (async () => { const server = new OAuth2Server(); // Start the server await server.start(8080); // Set the default userinfo response server.setUserInfo({ sub: '1234567890', name: 'John Doe', email: 'john@example.com', preferred_username: 'johndoe' }); console.log('Mock OAuth2 Server is running at', server.issuer); // To stop: await server.stop(); })();