oAuth Demo

oAuth-Authorization by retrieving frist a Token and then using this Token to get the needed JSON.
These steps are needed for that:

1. Put together the “Get-Token” request:
Put together a JCI-Template for retrieving the Token.
http://api.json-content-importer.com/extra/api/gettoken.php gives you a Token,
when retrieving via CURL-Post and the Postpayload (see JCI-Template field)
{“user”: “test”, “password”: “mypass”}
The Twig-Template “{{ _context.access_token}}” contains the Token.
You might set the cachetime of this JCI-Template (see field there)
to a time less thant the Token lifetime.
Check if this works by placing
[jsoncontentimporterpro id=NUMBER_OF_GETTOKEN_TEMPLATE]
on a page: You should see the Token.

2. Use the “Token”:
The get the needed data you have to send the Token to the API-URL. How? This depends on the API.
http://api.json-content-importer.com/extra/api/bearer.php?a=w expects sending
a Token in the Request-Header as “accesstoken:TOKEN”
To do that create another JCI-Template with that:
URL: http://api.json-content-importer.com/extra/api/bearer.php?a=w
Method: CURL-GET
CURLOPT_HTTPHEADER=accesstoken:#BRO#jsoncontentimporterpro id=NUMBER_OF_GETTOKEN_TEMPLATE#BRC#
The Shortcode in Curloptions will be executed (#BRO# stands for [ and #BRC# for ]) will be
executed and replaced by the Token (as described in 1.).
Time: {{time}}This page used the accesstoken "{{_context.usedaccesstoken}}",

3. FAQs on that:
  • The API expects a base64encoded Token:
    {% set token4base64encodeing = username ~ password %}
    {% set base64encodedToken = (token4base64encodeing | base64encode) %}

In action:
Time: Tue 10 2020, 04:48:42
This page used the accesstoken "a029d0df84eb5549c641e04a9ef389e5",
which was retrieved from
by passing the username and passwort to the API.