The implicit grant
The implicit grant handed a browser application its access token directly in the redirect, with no code to exchange. It answered real limits of 2012 browsers, and the way it failed explains why browser applications now use the authorization code flowThe main OAuth flow: the browser visits the authorization server, where the person signs in and approves access, then carries an authorization code back to the client, which exchanges it for tokens directly. When the client runs on a server, the tokens never pass through the browser. with PKCEProof Key for Code Exchange, pronounced pixie: the client creates a secret for each authorization attempt, sends only a hash of it at the start, and proves it holds the secret when redeeming the code, so a stolen authorization code is useless to anyone else..
How it worked
Imagine the photo editor at editor.example as it would have been built in 2012: a single page of JavaScript with no backend at all. It needed an access token for the photo APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests., and the obvious way for a page like that to get one was the implicit grant.
Choosing a flow listed it among the flows to avoid. Seeing how it worked, and why it once seemed reasonable, explains why its replacements look the way they do.
All domains and tokens in these examples are fictional. When Ava opened the editor, it sent her browser to the authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. endpoint with response_type=token:
https://auth.photos.example/authorize
?response_type=token
&client_id=photo-editor
&redirect_uri=https%3A%2F%2Feditor.example%2Foauth%2Fcallback
&scope=photos.read
&state=demo-attempt-25There is no PKCE challenge, because there would be no code to redeem. After Ava signed in and approved, the authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. sent the access token straight back in the redirect:
HTTP/1.1 302 Found
Location: https://editor.example/oauth/callback#access_token=demo-implicit-token-25&token_type=Bearer&expires_in=3600&state=demo-attempt-25The token sits after the #, in the URLA web address, such as https://photos.example/api/albums/42?limit=10. It names how to connect (https), the domain, the path to a particular page or resource, and any extra parameters after the question mark.'s fragment. Browsers do not send the fragment to the server when they load a page. The browser requested /oauth/callback from editor.example without it and received the editor's page. That page's script then read the fragment from the browser's current address, checked state, and kept the token in memory or in browser storage. The specification did not allow a refresh tokenA longer-lived credential that a client sends to the authorization server, never to an API, to get new access tokens without asking the person again. in this response.
Compare this with the authorization codeA short-lived, single-use value that the authorization server sends back to a client through the browser. The client swaps it for tokens in a direct request to the authorization server; APIs never accept it. flow. There is no token request, no client authenticationChecking evidence that someone, or some application, controls an account, such as a password or a passkey. It establishes which account is being used, not what that account may do., and no proof that the party receiving the token was the one that asked. The only thing tying the token to the editor is the registered redirect URI.
Why it existed
In 2012, a page's script could not count on being able to send a request to another origin, such as the authorization server's token endpointThe authorization server address where clients exchange an authorization code, refresh token, or other grant for tokens, in a direct request rather than through a browser redirect., and read the response. Cross-Origin Resource Sharing (CORS), the mechanism Browser applications described, was still being standardized and was not available in every browser people used. A code exchange needs exactly that request. The editor had no backend to make it instead, and as a public clientAn OAuth client, such as code running in a browser or an app on a phone, that cannot keep a credential secret because the people using it can inspect it. It relies on protections such as PKCE instead of a client secret. it had no credential to authenticate with anyway.
The implicit grant worked around all three problems. The token arrived through a navigation, which browsers had always allowed across origins, and the fragment kept it out of the editor's own server logs. RFC 6749 presented it as a simplified flow for clients running in a browser, while warning that its convenience should be weighed against its security costs, especially where the authorization code grant was available.
What went wrong
Putting the token in a URL exposed it to everything that handles URLs. The full address, fragment included, went into browser history. Any script on the callback page, including analytics and advertising code, could read it. Browser bugs occasionally leaked fragments through referrer headers. A token meant to pass only from the authorization server to the editor went through several places never designed to hold credentials.
Nothing bound the token to the client that received it. Suppose an attacker obtained a token for Ava's photos, perhaps through a malicious application she once approved. They could start a sign-in at a legitimate application that used the implicit grant, then replace the token in the returning fragment with the stolen one. The application could not tell: the state value was its own, and the token worked at the API. This access token injection was most damaging for applications that treated receiving a valid token as proof that a particular person had signed in, a misuse RFC 6749 itself warned against.
Without refresh tokens, the editor had to send Ava back to the authorization server whenever its token expired. To avoid interrupting her, applications repeated the authorization request in a hidden iframe, a page loaded invisibly inside another, and relied on her session cookieA small value that a website asks the browser to store and send back with later matching requests. Cookies commonly carry a session identifier, so the site can recognize an ongoing sign-in without your password. at the authorization server to approve it silently. That depended on browsers sending the authorization server's cookies inside a frame on another site, which browsers have since restricted, as Browser applications explained. And because the token was handed over in a redirect, there was no standard way to bind it to a key the client held, so the sender-constrained tokens that Advanced OAuth describes could not help.
Current guidance
The reasons for the workaround have gone. Browsers support CORS, so a page's script can call a token endpoint that allows it, and PKCE gives a public client a proof for each attempt without needing a secret. A browser application can run the authorization code flow with PKCE itself, as Browser applications described, or leave tokens to a backend for frontend.
The OAuth 2.0 Security Best Current Practice, RFC 9700, says clients SHOULD NOT use the implicit grant, or any other response type that returns an access token in the authorization response, unless access token injection is prevented and the leakage paths are mitigated. Meeting those conditions takes more machinery than simply using the code flow. For the clients that relied on the implicit grant most, a later best current practice removes even that path. RFC 10017, on browser-based applications, says browser-based clients MUST NOT use the implicit grant and that the authorization server MUST issue their access tokens only from the token endpoint. OAuth 2.1, the working group's consolidation of OAuth 2.0 and its later guidance, leaves response_type=token out entirely.
Existing implicit integrations still run in many places, often in applications nobody has needed to touch for years. Migrating older integrations looks at how to find them and move them without breaking the people who depend on them.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Turn on the implicit grant, read the fragment, and turn it offAllow the implicit grant for one temporary client, receive a token in the URL fragment, see where it ends up and what binds it to nothing, then replace it with the code flow and switch it off.