Preview API Documentation - Subject to change
Overview
Feedback Aide uses an oAuth security patterns to handle authentication.
A limited scope token is used for all API requests. To get a token you need to authenticate with your Learnosity oAuth key and secret.
Note - the oAuth key and secret is not the same as the standard Learnosity key and secret. Contact support if you need help.
To get a token you need to use your learnosity-oauth-key and learnosity-oauth-secret against the token endpoint - and it will return a token that you can use in your next requests.
In the examples below there are three variables that need to be replaced:
- your-learnosity-oauth-key - replace with the key provided to you.
- your-learnosity-oauth-secret - replace with the secret provided to you.
-
your-feedback-session-id - replace this with the
feedback_session_id
you want to access.
Curl Example
curl -X POST 'https://feedbackaide.learnosity.com/api/token' \
-u 'your-learnosity-oauth-key:your-learnosity-oauth-secret' \
-d 'grant_type=client_credentials' \
-d 'scope=api:feedbackaide feedback_session_uuid:your-feedback-session-id:RW'
This will return a token as follows:
{
"access_token": "3e1db5b8-68fd-497d-9221-c98f3d5bb457",
"token_type": "bearer",
"expires_in": 7200
}
Python Example
1. Firstly, install the required dependencies:
python -m venv oauthenv
source ouathenv/bin/activate
pip install requests requests-oauthlib
2. Create a sample Python code file, called oauth_test.py
from oauthlib.oauth2 import BackendApplicationClient
from requests.auth import HTTPBasicAuth
from requests_oauthlib import OAuth2Session
# Define the client ID, client secret, feedback_session_id and token URL
client_id = 'your-learnosity-oauth-key'
client_secret = 'your-learnosity-oauth-secret'
feedback_session_uuid = 'your-feedback-session-uuid'
token_url = 'https://feedbackaide.learnosity.com/api/token'
scope = ['api:feedbackaide', f'feedback_session_uuid:{feedback_session_uuid}:RW']
# Create an OAuth2 session and fetch the token
auth = HTTPBasicAuth(client_id, client_secret)
client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client)
token = oauth.fetch_token(token_url=token_url, auth=auth, scope=scope)
print(token)
python oauth_test.py
3. This will return a token as follows:
{
"access_token": "3e1db5b8-68fd-497d-9221-c98f3d5bb457",
"token_type": "bearer",
"expires_in": 7200
}
PHP Example
1. Firstly, install the Guzzle client:
composer require guzzlehttp/guzzle
2. Create a PHP test file as follows:
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
# Define the client ID, client secret, feedback_session_id and token URL
$client_id = 'your-learnosity-oauth-key'
$client_secret = 'your-learnosity-oauth-secret'
$feedback_session_uuid = 'your-feedback-session-uuid'
$token_url = 'https://feedbackaide.learnosity.com/api/token'
$response = $client->post(token_url, [
'auth' => [$client_id, $client_secret],
'form_params' => [
'grant_type' => 'client_credentials', // Per OAuth spec, Must always be included
'scope' => 'api:feedbackaide feedback_session_uuid:' . $feedback_session_uuid . ':RW',
],
]);
echo $response->getBody();
3. This will return the token as follows:
{
"access_token": "3e1db5b8-68fd-497d-9221-c98f3d5bb457",
"token_type": "bearer",
"expires_in": 7200
}