Consent redirect
Where Open Gateway sends the Consumer when the consent flow ends, and what the query string tells you.
When the consent flow ends, Open Gateway (OG) redirects the Consumer's browser back to your Software Product. The redirect goes to one of the URIs you supplied when you primed the agreement (see Prime a CDR sharing arrangement):
redirectUri: where the Consumer goes when consent succeeds.errorRedirectUri: where the Consumer goes when consent fails or is cancelled. It is optional; without it, OG usesredirectUrifor errors too.
Both URIs must be in the allowed_redirect_uris of the Agreement Template you prime with, or the prime request fails.
Use state to match the redirect to the session that primed the agreement. Pass a value you can look up, such as a
random, single-use session reference, and check it when the Consumer returns.
Consent successβ
When the Consumer completes the consent flow and the Data Holder authorises sharing, the agreement becomes ACTIVE and
OG redirects the Consumer to your redirectUri with these query parameters:
| Parameter | Value |
|---|---|
state | The state you passed in the prime request. If you did not supply state, the parameter is present but empty. |
agreementId | The ID of the agreement. It matches the agreementId returned by the prime request. |
Values are URL-encoded.
Sample URLβ
https://app.example.com/consent/complete?state=session-7f3a9c&agreementId=27a0d944-4eb7-452e-a63c-dc14d8f92428
Use agreementId, with the Consumer's principalId, to check the agreement
and then query data.
Consent errorβ
OG redirects the Consumer to your errorRedirectUri, or to your redirectUri if you did not supply one, in two cases:
the consent fails at the Data Holder, or the Consumer cancels on the consent screen. The parameters differ between them.
When the Data Holder returns an errorβ
If the Data Holder does not authorise sharing, for example because the Consumer declines there or authentication fails, OG redirects with these query parameters:
| Parameter | Value |
|---|---|
error | The error the Data Holder returned. |
errorDescription | The error description the Data Holder returned. |
errorUri | The error URI the Data Holder returned. |
state | The state you passed in the prime request. |
All four parameters are always present, and any of them can be empty. Values are URL-encoded.
Sample URLβ
https://app.example.com/consent/error?error=access_denied&errorDescription=Consumer+declined&errorUri=&state=session-7f3a9c
When the Consumer cancelsβ
If the Consumer cancels on the consent screen, Open Gateway redirects to your errorRedirectUri, or to your redirectUri if you did not supply one. error is cancelled and errorDescription is User has cancelled consent flow. errorUri is not sent, and state is sent only if you supplied one in the prime request.
| Parameter | Value |
|---|---|
error | cancelled |
errorDescription | User has cancelled consent flow |
state | The state you passed in the prime request. Not sent if you did not supply one. |
Sample URLβ
https://app.example.com/consent/error?error=cancelled&errorDescription=User+has+cancelled+consent+flow&state=session-7f3a9c
Handling the redirectβ
- Accept the parameters for both cases on your
errorRedirectUri, and onredirectUritoo if you do not supplyerrorRedirectUri. If your handler validates incoming parameters, make sure it acceptsstateon a cancelled consent. - Treat the redirect as a signal, not as proof: before you query data, check that the agreement's
statusisACTIVEwith Get Agreement Detail. - A Consumer who abandons the flow without cancelling is not redirected at all. The agreement then stays
PRIMEDorINIT.