Skip to main content

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 uses redirectUri for 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.

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:

ParameterValue
stateThe state you passed in the prime request. If you did not supply state, the parameter is present but empty.
agreementIdThe 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.

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:

ParameterValue
errorThe error the Data Holder returned.
errorDescriptionThe error description the Data Holder returned.
errorUriThe error URI the Data Holder returned.
stateThe 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.

ParameterValue
errorcancelled
errorDescriptionUser has cancelled consent flow
stateThe 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 on redirectUri too if you do not supply errorRedirectUri. If your handler validates incoming parameters, make sure it accepts state on a cancelled consent.
  • Treat the redirect as a signal, not as proof: before you query data, check that the agreement's status is ACTIVE with Get Agreement Detail.
  • A Consumer who abandons the flow without cancelling is not redirected at all. The agreement then stays PRIMED or INIT.