Value not getting persisted in connection in custom make app

:bullseye: What is your goal?

I have a verified app on make.com marketplace named Frejun. After some non breaking changes in our backend api were made, i tried to update the make.com custom app as well. I had to save the email query parameter that will be received in the response to be able to use that email query param on each subsequent request through BASE. But currently it’s not being saved similar to how I was able to save accessToken and refreshToken. I tried hardcoding it as well, but still it is not working. Please take a look at it so we can work on updating our make.com scenario

:thinking: What is the problem & what have you tried?

The problem is because the email is not getting persisted to BASE through connection which should be saved in the custom app’s connection section. Since connection.email comes out to be empty in the BASE, it leads to no email parameter being send to be able to register the webhook on the backend.
Why is the email not getting saved to connection?

:clipboard: Error messages or input/output bundles

Here is the BASE for my app

{
	// Default request configuration
	"baseUrl": "https://api.frejun.com/api/v2/",          // Default base URL for all modules and RPCs.
	"headers": {                                          // Default HTTP headers for all modules and RPCs.
		"authorization": "Bearer {{connection.accessToken}}"   // Authorization by API key, which user will provide in the connection as parameter.
	},
	"qs": {
        "email": "{{connection.email}}" 
    },

	// Default response handling
	"response": {
		"error": {                                        // Error handling
			"message": "[{{statusCode}}]-- {{body.error}}"  // On error, returns error message as "[statusCode] error text".
		}
	},

	"log": {
		"sanitize": [                                     // Excludes sensitive parameters from logs.
			"request.headers.authorization"
//            "request.qs.email"		
		]
	}
}

CONNECTION

{
	// Step 1: OAuth2 authorization request
	// See OAuth2 documentation: https://www.oauth.com/oauth2-servers/server-side-apps/authorization-code/
	"authorize": {
		"url": "https://product.frejun.com/oauth/authorize/",                      // Endpoint for authorization.
		"qs": {
			"client_id": "{{common.client_id}}"  // Client ID either provided in common parameters (below) or by the user.
		},

		// Authorization response handling
		// See OAuth2 documentation https://www.oauth.com/oauth2-servers/authorization/the-authorization-response/
		"response": {
		   // Store received "code" into temporary storage.
			"temp": {
				"code": "{{query.code}}",
				"email": "{{query.email}}"
			}
		}
	},

	// Step 2: OAuth2 token request
	"token": {
		"condition": "{{temp.code}}",                                     // Checks if "code" has been correctly received by authorization response.
		"url": "https://api.frejun.com/api/v2/oauth/token/",
		"headers": {
			"authorization": "Bearer {{ base64(common.client_id + ':' + common.client_secret) }}"
		},
		"qs": {
			"email": "{{temp.email}}",
			"code": "{{temp.code}}"                                      // Uses stored "code" from authorization response.
		},
		
		// Token response handling
		"response": {
			"data": {
				"expires": "{{addSeconds(now, body.expires_in)}}",        // Stores the expiration date of accessToken.
				"accessToken": "{{body.access_token}}",                   // Stores the accessToken.
				"refreshToken": "{{body.refresh_token}}",                  // Stores the refreshToken.
				"email": "chakri@frejun.com"
			}
		}
		// "log": {
		// 	"sanitize": [                                                 // Excludes sensitive parameters from logs.
		// 		"request.headers.authorization",
		// 		"request.body.code",
		// 		"request.body.client_secret",
		// 		"response.body.access_token",
		// 		"response.body.refresh_token"
		// 	]
		// }
	},

	// Step 3: Refresh token
	// See OAuth2 documentation https://www.oauth.com/oauth2-servers/access-tokens/refreshing-access-tokens/
	"refresh": {
		"condition": "{{data.expires < addMinutes(now, 1)}}",             // Executes the request if accessToken is expired.
		"url": "https://api.frejun.com/api/v2/oauth/token/refresh/",
		"method": "POST",
		"headers": {
			"authorization": "Bearer {{ base64(common.client_id + ':' + common.client_secret) }}"
		},
		"qs": {
			"email": "{{temp.email}}"
		},
		"body": {
			"refresh": "{{data.refreshToken}}"
		},
		"type": "urlencoded",
		"response": {
			"data": {
				"expires": "{{addSeconds(now, body.expires_in)}}",        // Stores the expiration date of the new accessToken.
				"accessToken": "{{body.access}}",                   // Stores the new accessToken.
				"refreshToken": "{{body.refresh}}",                  // Stores the new refreshToken.
				"email": "chakri@frejun.com"
			}
		}
		// "log": {
		// 	"sanitize": [
		// 		"request.headers.authorization",
		// 		"request.body.client_secret",
		// 		"request.body.refresh_token",
		// 		"response.body.access_token",
		// 		"response.body.refresh_token"
		// 	]
		// }
	}
}

Webhook ATTACH section

{
	// Request
	"url": "/integrations/webhooks/make/",
    // uses the qs from base
	"method": "POST",
	"body": {
		"event": "call.status",
		"callback_url": "{{webhook.url}}"
	},

	// Response handling
	"response": {
		"data": {
			"externalHookId": "{{body.data.id}}"  // Stores the webhook's ID to be used in the detach remote procedure. It is accessible via "{{webhook.externalHookId}}"
		},
		"error": {                                        // Error handling
			"message": "[{{statusCode}}] {{body.message}}"  // On error, returns error message as "[statusCode] error text".
		}
	}
}

:link: Create public scenario page

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Hey @Sahil1 !

The most likely reason is that you’re using an existing connection that was created before the email field was added to the connection data.

In Make, updating the connection spec does not backfill old connections. So even if you now return:

“email”: “chakri@frejun.com”

in the token response, older saved connections will still have no email value. That would explain why connection.email is empty in BASE and why the webhook attach call fails with “Missing required parameter: email”.

A couple of things to check:

Create a completely new connection and test with that one. Do not reuse the old saved connection.

If you need the email during refresh, use data.email rather than temp.email. Temp values are only available during the authorization flow, not as persistent connection data.

So this part:

“qs”: {
“email”: “{{temp.email}}”
}

is safer as:

“qs”: {
“email”: “{{data.email}}”
}

The main issue still looks like the connection itself was created before email was stored, so Make is sending an empty query param from the old connection.

So I’d try this first:
update the app
create a brand new connection
use that new connection when creating the webhook

If that works, then the problem is not BASE itself, but that the previous connection never had email saved into its data.

Dr. Tanvi Sachar
Monday Certified Partner, Tuesday Wizard

Hi @Ethan_Marcellus

Thanks for the response, I did try making new connections but it still doesn’t make a difference here. One more thing I tried was hard coding the email value in the BASE in qs, that seems to be working. so it means the issue is mostly about email not getting saved to the connection.

1 Like

You’re saving email into response.data, so it should be referenced as {{connection.email}} only after the connection is actually re-authorized.

A couple things stand out though:

  • temp.email is only available during the auth flow, so it won’t exist later in refresh/base unless it was first saved into data

  • if you added email after the connection was already created, the old connection may still not have that value

  • in refresh, using {{temp.email}} is probably the issue — you likely want {{data.email}} there instead

So I’d check two things first: change refresh to use data.email, then create a brand new connection and test again. Existing connections usually won’t magically get newly added stored fields.

Hi @Devtrest
Thanks for the response, As I had shared, I created new connections each time while testing so using old connections couldn’t cause this. email parameter is also not required param qs param in the token and refresh requests so we can also ignore the usage of temp.email there. Mostly I assumed it should be saved when hardcoding it as response.data.email as I did in the token and refresh part of connection section by setting it to ‘chakri@frejun.com’. Both token and refresh part is succeeding, only webhook creation (ATTACH) part fails because qs goes empty.

Got it! if you’re already testing with brand new connections each time, then yeah, old connections are not the issue here.

In that case, if token and refresh both succeed even with response.data.email hardcoded, but ATTACH still receives an empty qs.email, then it sounds like the value is simply not being persisted into the connection data the way expected.

So at that point I’d look less at temp.email / refresh, and more at whether email is actually supported/stored in connection data for later use in BASE and webhook calls in this app flow. Because based on what you described, the problem is really: connection.email is empty during ATTACH even though auth succeeds.

That makes this feel more like a persistence/app-definition issue than a testing issue on your side.

Yes thanks @Devtrest ,
I guess make.com does not support such variables and only has support for the basic ones like accessToken , refreshToken and expires inside of response.data as I tried changing name of the accessToken variable but then it did not persist to the connection directive inside of BASE.
Now it’s tricky to figure out a solution to save email though :thinking: