From IndieWeb
Jump to: navigation, search

An authorization endpoint is an HTTP endpoint that micropub and IndieAuth clients can use to identify a user or obtain an authorization code (which is then later exchanged for an access token) to be able to post to their website.


Creating an Authorization Endpoint

An authorization endpoint must be able to both generate authorization codes as well as verify the authorization codes it issues.

Web Sign-In Form

The site contains a web sign-in form prompting the user to enter their personal web address to sign in. Upon submitting the form, the site begins the auth process by discovering the user's auth endpoint, e.g.:


See for more UI details / possibilities.

Identification header

Every endpoint MUST return a

IndieAuth: authorization_endpoint

HTTP header in all responses.

This is used by clients to verify that the server understands the IndieAuth protocol.


The web application checks the user's website for a link with a rel-value of "authorization_endpoint":

<link rel="authorization_endpoint" href="">

Use this URL as endpoint for processing.

Authorization Endpoint

To start the sign-in flow, the user's browser will be redirected to their authorization endpoint, with additional parameters in the query string.

Directing the user's browser to the auth endpoint is usually done via a HTTP Location header, but can optionally be an <a> tag with an href set to the authorization URL.


Note: Values are shown with extra linebreaks and without URL encoding for readability.


Full URI of the user's homepage
Full URI of the application's/website's home page. Used to identify the application. An authorization endpoint may show the application's icon and title to the user during the auth process.
Full URI to redirect back to when the login process is finished
Web application-internal state variable; can contain anything
Optional. Auth endpoints MUST support them, though.
id (identification only) or code (identification + authorization)
Optional. Defaults to id.
Not used and omitted in identification mode (response_type=id)
For authorization, the scope contains a space-separated list of scopes that the web application requests permission for, e.g. "create". Multiple values are supported, e.g. create delete

Redirect URI verification

why is redirect_uri separate from state?
the callback URL shouldn't be dynamic per request so that callback URLs can be registered. "state" is allowed to vary per request
why should callback urls be registered?
without registration it's easier to perform a redirect attack. more background here:
how does the client website register the callback at the server?
haven't written this part up yet, but the idea is for the client to publish its registered redirect URIs on its web page with a <link> tag
since client IDs are always URLs, it's all discoverable that way
for client_id a server can find its valid redirect URIs by looking for
<link rel="redirect_uri" href="">

Verify the user

The authorization server should present an interface describing the request being made. It must indicate:

The client_id making the request
Optionally the server can include the name and logo if an h-card is found on the client_id URL.
The scope if authorization is requested.


TODO: Example. See h-x-app.

Redirect to web application

The authorization server presents the request information to the user, and if they approve, generates an authorization code and redirects the user to the redirect URI specified.

HTTP/1.1 302 Found


Authorization code
State variable sent by the web application
Full URI of the user's homepage
This may be different from the me parameter that the user originally entered, but MUST be on the same domain.

Auth code verification

For the sign-in flow, the web application will query the authorization endpoint to verify the auth code it received. The client makes a POST request to the authorization server with the following values:

Content-type: application/x-www-form-urlencoded


After the authorization server verifies that redirect_uri, client_id match the code given, the response will include the "me" value indicating the URL of the user who signed in. The response content-type should be either application/x-www-form-urlencoded or application/json depending on the value of the HTTP Accept header.

HTTP/1.1 200 OK
Content-Type: application/x-www-form-urlencoded

HTTP/1.1 200 OK
Content-Type: application/json

  "me": ""


Full URI of the user's homepage
This may be different from the me parameter that the user originally entered, but MUST be on the same domain.
This MUST be the same as the me parameter that "redirect to web application" returned.

Use by Token Endpoints

When used in the flow for obtaining an access token that can create posts using Micropub, the token endpoint will be making the request to verify the authorization code, rather than the client. In this case, the client will make the request described above to the token endpoint instead. If the token endpoint and authorization endpoint are part of the same software, then of course the token endpoint can verify the authorization code using a proprietary method, such as looking up the code from the same database that the authorization endpoint stored it in.

Using an Authorization Service

You can use an existing authorization service such as if you don't want to build your own authorization service.


Why are auth codes verified with a POST instead of a GET

If auth codes are sent as a GET request in the query string, they may leak to log files or the HTTP "referer". The decision was made by the OAuth 2.0 working group to use POST requests and the HTTP Authorization header for sending these sensitive tokens and auth codes.

Can the authorization codes be used more than once

No, the authorization code must not be used more than once. If the code is used more than once, the authorization server must deny the request.[1] A maximum lifetime of 10 minutes is recommended for the authorization codes, although many implementations have a lifetime of 30-60 seconds.

Can I add additional parameters for the authorization request

No, but you can use the "state" parameter to encode or reference additional application-specific parameters. The state parameter will be passed around and was designed for this purpose as well as to prevent CSRF attacks.

Does the auth server have to support the state parameter

Yes, the state parameter can be used by the client to maintain state between the request and the callback, so the auth server must support it. It is also used to prevent CSRF attacks.

Software implementing the authorization endpoint spec

See Also

Personal tools
Recent & Upcoming