Skip to main content
Dev · 283 tools

Mock OAuth Token Response Generator

Generates a realistic fake OAuth 2.0 token response as JSON for testing

Token ResponseExample — click Generate for yours
{ "access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImE3YTU2YmUxNWVjMiJ9.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmV4YW1wbGUubmV0LyIsInN1YiI6InUtNDQ4MTcyNjMiLCJhdWQiOiJtb2JpbGUtYXBwIiwiaWF0IjoxNzk1ODQ4ODQ4LCJleHAiOjE3OTU4NTE1NDgsInNjb3BlIjoiYXBpIGZ1bGwgd2ViIn0.lmbz4IN5jZeTuroYuRRjc4Mntvr8rSWXQAJzgxP0ZnGxguxGwqjhPr5tNsWog8XX1T4CJC3FRz9", "token_type": "Bearer", "expires_in": 2700, "scope": "api full web" }

Generated 12 words · 419 characters

See 3 examples
  • Example 1
    {
      "access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImE3YTU2YmUxNWVjMiJ9.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmV4YW1wbGUubmV0LyIsInN1YiI6InUtNDQ4MTcyNjMiLCJhdWQiOiJtb2JpbGUtYXBwIiwiaWF0IjoxNzk1ODQ4ODQ4LCJleHAiOjE3OTU4NTE1NDgsInNjb3BlIjoiYXBpIGZ1bGwgd2ViIn0.lmbz4IN5jZeTuroYuRRjc4Mntvr8rSWXQAJzgxP0ZnGxguxGwqjhPr5tNsWog8XX1T4CJC3FRz9",
      "token_type": "Bearer",
      "expires_in": 2700,
      "scope": "api full web"
    }
  • Example 2
    {
      "access_token": "at_5JzRoVby8HAEwHUOIR4Fgp739KtTL0PWbHkD7LHoktm2EUQ84Qn6",
      "token_type": "Bearer",
      "expires_in": 876,
      "scope": "read:user read:discussion"
    }
  • Example 3
    {
      "access_token": "tok_3F49n9l33DWKJJC29GbNmjpaO2YC6D8Jeklaz8nSEpz1lEy7e9",
      "token_type": "Bearer",
      "expires_in": 1794,
      "refresh_token": "WVabzJaCt9LB5URF4do5oaFpJShdL5TpEsu-Xwu63iMB6Ua5GznyNjZ53cKf81dS",
      "refresh_token_expires_in": 2591540,
      "scope": "read:repo read:discussion write:repo",
      "created_at": 1795848339
    }

About this generator

Token-handling code — parsing the response, storing the access token, scheduling a refresh before expiry — is straightforward to unit-test once you have a realistic response object to work with. Getting that object without calling a real authorization server means maintaining a hardcoded JSON fixture, which goes stale. This tool generates a fresh, well-formed OAuth 2.0 token response on demand. Every response has access_token, token_type (always Bearer), expires_in and scope. The access token is an opaque random string, a prefixed token, or a fake JWT-shaped string with issuer, subject, audience and expiry claims. expires_in uses realistic lifetimes — fixed values from five minutes to a day, values a few seconds under an hour as some servers return, or a randomized 60–90 minute window. Most responses also carry a refresh_token, sometimes with refresh_token_expires_in; scopes are drawn from several naming styles (OpenID Connect, read/write, resource:action, URL scopes), and when openid is requested an id_token is included. Some responses add created_at or jti, as certain servers do. Paste the JSON into a test fixture or mock server handler. Use it to test that your code correctly reads the access_token, respects the expires_in value when scheduling a refresh, copes with optional fields being present or missing, and stores the refresh_token. For integration tests, swap in real responses from your identity provider rather than the mock.

How to use

  1. Click Generate to produce a token response.
  2. Copy the JSON into your test or mock server.
  3. Use it to exercise token-handling code.
  4. Swap in real responses for integration tests.

Use Cases

  • •Testing OAuth token-handling code
  • •Building a mock auth endpoint
  • •Demoing a token refresh flow
  • •Seeding an API client with a sample token
  • •Exercising token storage and expiry logic

Tips

  • →Use it to test parsing and storage safely.
  • →The tokens authenticate nothing.
  • →Test real flows against your provider.
  • →Cover expiry and refresh handling.

FAQ

what fields are in an OAuth token response

A standard OAuth 2.0 token response includes access_token, token_type (usually Bearer), expires_in seconds, and often a refresh_token and a scope. This mock includes all of them so your code can parse and handle a realistic payload.

do these tokens actually work

No. The token strings are random and authenticate against nothing, which is exactly why they are safe to use in tests and demos. They let you exercise parsing, storage, and expiry logic without touching a real authorization server.

when should I use real token responses

During integration testing against your actual identity provider. The mock is perfect for unit tests and building your handling logic in isolation, but real flows — including error cases and provider-specific fields — should be tested against the live service.

You might also like

Popular tools from other categories that share themes with this one.