Failed to set scopes when creating new connection programmatically via Make API

I need to create new scoped google drive connection with Make API call, I’ve created app in google cloud console with all needed scopes, redirect urls etc. got client id and secret and provided all parameters as described in Make API docs:

query = f'https://eu2.make.com/api/v2/connections'
body = {'accountName': 'New Google Drive for test',
        "accountType": "google",
        "clientId": 'id',
        "clientSecret": 'secret',
        "scopes": ['https://www.googleapis.com/auth/drive']}
params = {"teamId": TEAM_ID}
response = requests.post(query, json=body, headers=HEADERS, params=params)

Response:

{'connection': {'id': connectionID,
  'name': 'New Google Drive for test',
  'accountName': 'google',
  'accountLabel': 'Google',
  'packageName': None,
  'expire': None,
  'metadata': None,
  'teamId': teamID,
  'theme': '#fecd5f',
  'upgradeable': False,
  'scopes': 0,
  'scoped': True,
  'accountType': 'oauth',
  'editable': False,
  'uid': None}}

API call performed successfully but without provided scopes, also I can’t see created connection in my connections page.
Here’s what I’m getting when use API call to test if it is scoped:

query = f'https://eu2.make.com/api/v2/connections/{connectionId}/scoped'
body = {"scope": "https://www.googleapis.com/auth/drive"}
params = {"teamId": TEAM_ID}
response = requests.post(query, headers=HEADERS, params=params, json=body)

Response:

{'connection': {'scoped': False}}

My Make api key for these calls has following scopes: ‘connections:write’, ‘connections:read’

@Tiwa_Shada @Iveta_Sofkova

Hi @Daniil_Ornat , I have some experience in this topic that I can certainly share.

I just posted a whole bunch of details related to this topic on this post. You’ll want to review that as it relates to the challenge you are encountering.

Essentially, the scopes aren’t listed in the Make connection until the actual authorization (with the 3rd party provider) is completed. General steps are:

  1. Create connection in Make
  2. Get redirect URL from Make
  3. Use that URL to redirect the user to the 3rd party (that url includes your originally requested scopes)
  4. Once the user authorizes the scopes, and you verify the connection, you’ll be able to see the scope in the Make connection (because, at that point, they were actually authorized).

I hope that is useful.

2 Likes