The OAuth2 / OpenID Connect Mock
This is a simulation of an OAuth2 / OpenID Connect login service that you can use as a drop-in replacement for the real thing during testing. It’s free to use, and completely stateless so can accommodate virtually any number of concurrent clients (at least until the server runs out of breath!).
authorization_code (server-side web) OAuth2 flow is supported.
Using with your app
Start by finding the OAuth2 configuration in your app’s server-side component. Where this is located varies from app to app - sometimes it can be found in a configuration file, other times it is set directly in code. If you’re using an SDK from your login service, you may need to override the defaults this provides.
Set the following values:
- Authorization URI:
- Token URI:
- User info URI:
- JWKS URI:
You can see here how this is done in a Spring Boot application.
After that, when you start the login process from your app you should be sent to a simulated login page, rather than the one belonging to your real provider. You can log in with any email address and password you like, real or not.
If you just want to see this simulation in action, this demo app shows the OAuth2 and OpenID Connect flows in action. Full source code for the demo is available.
Making and customising your own OAuth2 mock
If you’d like to enhance or modify this simulation, you can select OAuth2 / OpenID Connect as a template when creating a new API in MockLab:
This will pre-load your API with all the necessary stubs, which you can modify and add to in the usual way.
Questions and feedback
If you’re not sure how something works or have a suggestion for improving this simulation, please get in touch with us via firstname.lastname@example.org or the chat widget.