From f73f5ef50f48b39b810577c2155290078387dc13 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Fri, 11 Sep 2020 00:08:51 +0200 Subject: [PATCH] Change OAuth doc in apiLive.htm (FINERACT-629) --- .../resources/static/api-docs/apiLive.htm | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/fineract-provider/src/main/resources/static/api-docs/apiLive.htm b/fineract-provider/src/main/resources/static/api-docs/apiLive.htm index 129b099fa..d08103fb6 100644 --- a/fineract-provider/src/main/resources/static/api-docs/apiLive.htm +++ b/fineract-provider/src/main/resources/static/api-docs/apiLive.htm @@ -4402,22 +4402,28 @@ function executeAjaxRequest(url, verbType, jsonData, basicAuthKey, successFuncti
-// A Javascript/Jquery example of how to login to Apache Fineract and use its api. -// Typically, the javascript application would +// A Javascript/JQuery example of how to login to Apache Fineract and use its API. +// Typically, the JavaScript application would: // 1) Display a login page to retrieve the username and password. // 2) Send the username, password, client_id , grant_type and client_secret to a function -// such as getOauthToken below which sets the HTTP bearer Auth key. +// such as getOauthToken() below which POSTs these as x-www-form-urlencoded (but NOT in the URL, see FINERACT-629) +// and stores the token in a global variable. // 3) The HTTP bearer Auth key is used in all subsequent requests -// (see the function executeAjaxRequest below). +// (see the function executeAjaxRequest() below). function getOauthToken(username, password) { var jqxhr = $.ajax({ - url : "/fineract-provider/api/oauth/token?username=" + credentials.username + "&password=" + credentials.password +"&client_id=community-app&grant_type=password&client_secret=123, + url : "/fineract-provider/api/oauth/token", type : 'POST', - contentType : "application/json; charset=utf-8", dataType : 'json', - data : "{}", + data : { + username: credentials.username, + password: credentials.password, + client_id: "community-app", + grant_type: "password", + client_secret: "123" + }, cache : false, success : function(data, textStatus, jqXHR) { authKey = data.access_token;