How to pass custom parameter to a custom OAuth2 connection?

As mentioned in the comments, the additional parameters that can be sent need to be recognized by the receiving endpoint which is mostly expecting OpenID Connect/OAuth2 standards parameters or some custom parameters already being used by popular providers. For example, this would be the case for the access_type parameter mentioned in the docs.

Despite this requirement custom OAuth2 connections can be configured to automatically map a known and accepted parameter, like the access_type one, to a custom parameter that is completely specific to the OAuth2 provider being configured. This automatic mapping is achievable by creating the connection with an authParamsMap options, for example:

{
  "name": "custom_oauth2",
  "options": {
    "client_id": "sad",
    "client_secret": "asd",
    // Other configuration parameters
    "authParamsMap": {
      "your_custom_param_here": "access_type"
    }
  },
  "strategy": "oauth2"
}

The above example would mean that when you pass an access_type parameter to /authorize and you requested the use of this custom connection then the value contained within the access_type parameter received in the authorization endpoint would be sent to the custom OAuth2 provide within the your_custom_param_here parameter.

This implies that the custom provider in question does not require the access_type parameter that is being mapped, however, given that’s a parameter that is being recognized due to the use by Google it’s highly unlikely that your custom provider requires it and as such is a good candidate for this mapping approach.

Finally, note that this option is not exposed through the extension you used so you’ll need to either create the connection through the Management API directly or patch an existing one created by the extension.

1 Like