Make: Difference between revisions

Jump to navigation Jump to search
IuriRosa (talk | contribs)
IuriRosa (talk | contribs)
Line 586: Line 586:
<div class="mw-collapsible-content">
<div class="mw-collapsible-content">


'''Connecting Make to Beds24 API V2'''
Before using API V2 with Make, we need to set up a data store to store the refresh token and the access token. We will also need to create a scenario that triggers every 24 hours to obtain a new token using the refresh token. Once this is set up, we can configure any scenario in Make using the Beds24 API V2, as we will always have an up-to-date token.
== Step 1: Create a Data Store ==
1. Log into Make and go to '''More''' (the 2 dots) > '''Data Store'''.
[[Image:Image1.png|700px|link=]]
[[Media:Image1.png|view large]]
2. Click the '''Add Data Store''' button in the top right corner.
[[Image:Image3.png|700px|link=]]
[[Media:Image3.png|view large]]
=== Configure the Data Store ===
1. Give the data store a name (I suggest "Access Token").
2. In the '''Data Structure''', click '''Add'''.
[[Image:Image4.png|700px|link=]]
[[Media:Image4.png|view large]]
  * Click '''Add Item''' and set:
    * '''Name''' = “Access Token”
    * '''Type''' = Text
    * '''Required''' = No
    * '''Multi-line''' = No
[[Image:Image5.png|700px|link=]]
[[Media:Image5.png|view large]]
3. Click '''Add New Item''' and set:
[[Image:Image6.png|700px|link=]]
[[Media:Image6.png|view large]]
  * '''Name''' = "Refresh Token"
  * '''Type''' = Text
  * '''Required''' = No
  * '''Multi-line''' = No
  * '''Strict''' = No
4. Click '''Save''' to save the data structure and the data store.
5. Now click '''Browse''' to find the data store you just created.
[[Image:Image7.png|700px|link=]]
[[Media:Image7.png|view large]]
6. Click '''Add''' at the top of the screen.
[[Image:Image8.png|700px|link=]]
[[Media:Image8.png|view large]]
7. You will need to add a key. Click the icon and enter a random number; you will need this number later for your scenario.
[[Image:Image9.png|700px|link=]]
[[Media:Image9.png|view large]]
== Step 2: Get Tokens from Beds24 ==
1. Log in to Beds24 and navigate to '''Settings > Apps & Integrations > API''' to generate a new invite code.
2. After you have the invite code, visit [https://api.beds24.com/v2/#/Authentication/get_authentication_setup Beds24 API Authentication Setup].
3. Click '''Try Out''' and paste your invite code.
[[Image:Image10.png|700px|link=]]
[[Media:Image10.png|view large]]
4. Click '''Execute''' to retrieve your token and refresh token.
[[Image:Image11.png|700px|link=]]
[[Media:Image11.png|view large]]
5. Copy the access token and paste it into the "Access Token" field in the data store.
6. Copy the refresh token and paste it into the "Refresh Token" field in the data store.
[[Image:Image12.png|700px|link=]]
[[Media:Image12.png|view large]]
7. Click '''Save''' at the top of the screen. You now have a data store containing your token and refresh token.
== Step 3: Create a Scenario to Update the Token Every 24 Hours ==
1. Create a new scenario in Make, and add the first module as '''Data Store – Search Record'''.
[[Image:Image13.png|700px|link=]]
[[Media:Image13.png|view large]]
  * Select '''Browse''' and choose the data store you created.
  * In the filter, choose the '''Access Token'''.
  * Set '''Basic Operation''' = Exist (this is important to check if the token exists).
[[Image:Image14.png|700px|link=]]
[[Media:Image14.png|view large]]
2. Click '''OK''' and add the second module.
3. Add an '''HTTP module – Make a Request''' to request a new token every 24 hours:
  * Set '''Evaluate all states as errors''' (except for 2xx and 3xx) = No.
  * '''URL''' = https://api.beds24.com/v2/authentication/token.
  * '''Method''' = GET.
  * In the headers, add two items:
    * '''Item 1''': Name = '''refreshToken''', Value = map the refresh token from the first module (Data Store module).
[[Image:Image16.png|700px|link=]]
[[Media:Image16.png|view large]]
    * '''Item 2''': Name = '''accept''', Value = '''application/json'''.
4. Save the module.
5. Add another module to update the token: '''Data Store – Add / Replace Record'''.
  * Select the data store you created.
  * '''Key''' = the random number you set earlier.
  * '''Overwrite an existing record''' = Yes.
  * '''Parse response''' = Yes (this is crucial).
6. You will need to run the HTTP module once before proceeding. Save the data store module as is for now.
[[Image:Image17.png|700px|link=]]
[[Media:Image17.png|view large]]
7. Copy your refresh token again and paste it into the "Refresh Token" field.
[[Image:Image18.png|700px|link=]]
[[Media:Image18.png|view large]]
8. Click '''OK''' to run the module and update your token.
[[Image:Image19.png|700px|link=]]
[[Media:Image19.png|view large]]
== Step 4: Finalize the Scenario ==
1. Edit the last module (Data Store) again, and map:
  * '''Access Token''' = Token from the HTTP module.
  * '''Refresh Token''' = Refresh token from the Data Store module.
[[Image:Image20.png|700px|link=]]
[[Media:Image20.png|view large]]
2. Save the module and set it to trigger every 24 hours. This will make an API call every day to get a new token.
== Step 5: Using the Token in API Calls ==
To make API calls to Beds24, first set the '''Data Store module – Get a Record'''. Insert your key (the number you set under Key). When you set up an HTTP module to make an API call, use the token from the data store, which will always be up to date.


</div>
</div>
</div>
</div>