PRO: oAuth2-Demo by using Shortcode in twig-code

This page shows you how to get access to the data at

This API / URL expects:

  • Useragent: mozilla
  • HTTP-Header with “Authorization:Bearer TOKEN”
  • “TOKEN” has to be obtained from
    For that user / password has to be sent by CURL-POST.

This is called oAuth2, to avoid sending user/password via http, but a TOKEN the API can check if user/password is ok.

We need two JCI-Shortcodes for that.

JCI-Template 1: The Shortcode (orderofshortcodeeval=1 tells the plugin first to execute the twig code and then the Shortcode – 10 would not execute the Shortcode, then you can see the TOKEN…)

[jsoncontentimporterpro nameoftemplate="demo-oauth" orderofshortcodeeval=1 httpstatuscodemustbe200=no]

is for the page that will show us the data.

Defined it like this:

  • Name: demo-oauth
  • URL:
  • method: CURL-POST
  • curloptions:
CURLOPT_POSTFIELDS={"user": "test", "password": "mypass"}
  • twig-template:
access_token: {{access_token | striptags}}<br>
[jsoncontentimporterpro nameoftemplate="demo-oauth2" curloptions="CURLOPT_USERAGENT=mozilla;CURLOPT_HTTPHEADER=Authorization:Bearer {{access_token | striptags}}"]

Ok, we need JCI-Template 2:

  • name: demo-oauth2
  • URL:
  • method: CURL-GET
  • curloptions: are sent from the other JCI-Template, where this Shortcode is used
  • twig-template:
{% if datasuccess %}
{% for b in boat %}
boat-id: {{}}<br>
{% endfor %}
{% for h in harbour %}
harbour-id: {{}}<br>
{% endfor %}
{% endif %}

In Action:

access_token: a029d0df84eb5549c641e04a9ef389e5
boat-id: 45353
boat-id: 324254
boat-id: 6456
boat-id: 287633536
boat-id: 35353
boat-id: 87686

harbour-id: 1425
harbour-id: 96534