Send the pilot to the consent screen
Redirect his browser to:
The pilot signs in to MyPilotIndex if he is not signed in, reads which of his data you ask for, and allows or denies.
The return
- Allowed: his browser goes to your
redirect_uriwithcodeandstateadded. - Denied: his browser goes to your
redirect_uriwitherror=access_deniedandstate. - A request MyPilotIndex refuses (an unknown partner, a redirect URI that is not registered, a scope that is not allowed) shows an error on MyPilotIndex and does not redirect.
The code
The code is valid for 10 minutes and works once. A code that is expired, used, issued to another partner, or paired with a wrong verifier or redirect URI is refused the same way: restart the consent.The exchange
CallPOST /v1/partner/grants/exchange with your bearer token and a JSON body of exactly code, code_verifier (43 to 128 characters) and redirect_uri. The answer holds:
grant_id, which every later call names;pilot.id, the pilot’s pairwise id;scopes, what the pilot granted, sorted;- with the
profilescope also hisname,usernameandavatar_url, each null when he has none.
400 invalid_request with reason invalid_grant, whatever was wrong. A malformed body (an unknown or repeated member, or a value that is not a string) is also 400 invalid_request, with no reason.
Sign in with MyPilotIndex
The pairwise id is stable across reconnects of the same pilot to your application, different at every partner, and never the MyPilotIndex account id. You can use it to sign the pilot in to your own product (“Sign in with MyPilotIndex”) and to name him on later calls.Revocation
The pilot can disconnect you in Settings, Privacy, Connected apps. MyPilotIndex can also revoke a grant. From then on every call naming the grant answers404 not_found, and, when a webhook URL is on record for you, you receive a grant.revoked webhook. If the pilot deletes his account the grant is removed with it. Delete what you hold for that pilot.

