How to use Gandi’s OAuth2 Server¶
The OAuth2 server is available at https://id.gandi.net
The OAuth2 authorization protocol is done in two steps, where we share secrets with one third party but not the other.
the first step is a request from the browser to the server
the second is a request from server to server.
Below is some information about the urls available on the id.gandi.net service:
/token¶
This url is used to fabricate a couple of confidential tokens for the client application.
Neither the “access token” or the “refresh token” must be plainly exposed either in the application or outside the application. The tokens must be stored in a session. The sessions (cookies) must imperatively be encrypted. Gandi reserves the right to deactivate any application that does not respect this technical constraint.
This url is therefore an API that is only used server-to-server, with the application/x-www-form-urlencoded formatted HTTP POST parameters as follows:
client_id¶
Provided during the registration of the application.
This identifies the client that is making the authorization for the user.
client_secret¶
Provided during the registration of the application.
This identifies the client. The secret can not be shared by multiple clients.
refresh_token¶
If grant_type = refresh_token, it contains the refresh token to consume.
code¶
If grant_type = authorization_code, it contains the authorization code to consume.
An authorization code can only be consumed once.
When grant_type = authorization_code, the RFC does not plan on the client_secret being sent. Consequently, the client is not authenticated. See: https://tools.ietf.org/html/rfc6749#page-30
Instead, we send the initial callback url https://id.gandi.net ignores the redirect_uri parameter for this request. It is not identified, and the redirection has already been performed on the legitimate url because it was predefined in advance.
The RFC does not therefore secure the delivery of the first access/refresh token. Gandi has taken the decision to give priority to security over the respect of the standard.
Incidentially google has also made this choice: https://developers.google.com/identity/protocols/OAuth2WebServer#handlingresponse
Github goes even farther: https://developer.github.com/v3/oauth/#github-redirects-back-to-your-site
This url returns a json document containing an access_token, a refresh_token, as well as an expires_in property that contains a TTL, in seconds, for the access token. The refresh_token never expires.
/tokeninfo¶
See https://tools.ietf.org/html/rfc6749#page-49.
This url is a server-to-server API since it consumes an access token.
This is therfore the first oauth2 API to call. It does not require any particular scope.
It returns the uuid (user_id, which never changes) of the authenticated user, the username of the user (which can be changed), the expires_in property (the remaining TTL in seconds of the access token), as well as the scope of the token.
GET /tokeninfo
Authorization: Bearer fgndfg-access-token-wefqz
Returns
{"user_id": "9811c27a-cfd1-11e9-a423-00163ee24379",
"expires_in": 3598,
}
or
{"username": "johnhsmith",
"lang": "en",
"user_id": "9811c27a-cfd1-11e9-a423-00163ee24379",
"expires_in": 3598,
"scope": ["account:public"]
}
If you want to get more information on the user account, please refer to the following page for instructions: https://api.gandi.net/docs/organization/#v5-organization-user-info
Note that doing so requires the ‘organization:view’ scope).