The OAuth2 / OpenID Connect Mock
Using 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!).
Currently the 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:
https://oauth.wiremockapi.cloud/oauth/authorize
- Token URI:
https://oauth.wiremockapi.cloud/oauth/token
- User info URI:
https://oauth.wiremockapi.cloud/userinfo
- JWKS URI:
https://oauth.wiremockapi.cloud/.well-known/jwks.json
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.
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 WireMock Cloud:
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 info@wiremock.io or the chat widget.