Jump to content
  • 0

2 Questions About Authentication and Website Load


JoellaLoge
 Share

Question

Developing an application that uses the Caspio API and facing weird issues with caspio api.For 3 days, I'm not able to understand the issue. 

I have posted many articles on different forums, but no good answers. Right now, I am getting 400 Status code message on implementing the solution. What is going wrong in the solution?

I am doing authentication using CASPIO below:
As an alternative to including credentials in the request body. I am including credentials in the body. Right now, a client can easily use HTTP basic authentication. In my method, I am following the following way of authenticating:

Method in PHP: Post
URL I am trying to use: Endpoint
Body of the code: access_type = login and password of client

Codes:

Javascript

var Currentfuncuser = "clientID";
var funcuserPass = "secretKey";

function authenticatetheUser(funcuser, funcuserPass)
{
    var authtok = funcuser + ":" + funcuserPass;

    // Should i be encoding this value????? does it matter???
    // Base64 Encoding -> btoa
    var currentH = btoa(authtok); 

    return "Simple" + currentH;
}

function CallingtheAPI() {

    // New XMLHTTPRequest
    var newXMLRequest = new XMLHttpRequest();
    newXMLRequest.open("POST", "https://xxx123.caspio.com/oauth/token", false);
    newXMLRequest.setRequestHeader("Authorization", authenticatefuncuser(Currentfuncuser, funcuserPass));  
    newXMLRequest.send();
    // view request status
    alert(newXMLRequest.status);
    response.innerHTML = newXMLRequest.responseText;
}

HTML

<div>
<div id="response">

</div>
<input type="button" class="primary" value="Simple API Call" onclick="javascript:CallingtheAPI;" />

Solutions tried:
Someone told that you need oAuth authentication protocol rather than simple authentication. After that have to set 'setHeaderRequest', with changes. 

Another Issue:
I am handling some clients websites. And when, I tried to work with maps API, which are currently telling the locations of the bases. And also, multiple zoom-in maps on the directory pages, but the pages are loading slowly. Example, militarybases.....navy-base-kitsap-navy-base-in-silverdale-wa/ contain only 1 map. And I want to host multiple maps(which is necessary in order to show the clearly zoomed-in location). It is the test phase, if successful. I have to integrate the full site. 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hello JoellaLoge,

As far as I know, in the body of the request should be  the following text:

grant_type=client_credentials&client_id=Client ID&client_secret=Client Secret

You can see details in the article:

https://howto.caspio.com/integration/web-services-api/rest-api/authenticating-rest/

 

When you say about maps, do you mean map mashup?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...