Get Authentication Token

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Hello Guys,

We are trying to implement Reckon One API. I got success to get records from your website as discussed on below link:


https://reckonproduction.portal.azure-api.net/


I tried to implement the same thing in code, but I am not able to get the token. I tried but didn't succeed. 


I have used the attached code, please correct me where I am doing wrong:


The output I am getting from the following Request:


In Console:
Inline image 1



In Network Tab:


Inline image 2




Please help me work around. 


Wish and hope to hear back from you asap. 
Photo of Ram Singh

Ram Singh

  • 110 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Jason Hollis

Jason Hollis, Head of Product

  • 10,278 Points 10k badge 2x thumb
Hi Ram,

Your code snippets (images) dont seem to be visable?? Can you copy directly into the forum?
(Edited)
Photo of Ram Singh

Ram Singh

  • 110 Points 100 badge 2x thumb
var params = {
// Request parameters
grant_type: 'password',
username: 'xxxxxx@xxxxxx.com',
password: 'xxxxxx',
scope: 'read+write',
Authorization: 'Basic MTIzNDo1xxxx',
MTIzNDo1Njc4: 'xxxxxxxx-xxxx-4xxx-9xxx-7fd287c9f06e:88dee5d7-ff30-4cc8-b360-22b27xxxxxx'
};

$.ajax({
url: "https://identity.reckon.com/connect/token?" + $.param(params),
beforeSend: function (xhrObj) {
xhrObj.setRequestHeader("Authorization", "Basic MTIzNDo1xxxx");
xhrObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// Request headers
},
type: "POST",
// Request body
data: "{body}",
})
.done(function (data) {
console.log(data);
alert("success");
})
.fail(function () {
alert("error"); 
});
(Edited)
Photo of Jason Hollis

Jason Hollis, Head of Product

  • 10,278 Points 10k badge 2x thumb
Hi Ram, 

It's most likely the grant type of the authorization that you are expecting. We use Authorization Code by default for OAuth2. We do have a support ticket where I think you have requested Resource Owner. Is that correct?
Photo of Ram Singh

Ram Singh

  • 110 Points 100 badge 2x thumb
Hi Jason,

Yes, i requested, but not sure if it is the correct for me.. 
Photo of Jason Hollis

Jason Hollis, Head of Product

  • 10,278 Points 10k badge 2x thumb
You now have the resource owner flow type assigned to your Identity Server credentials Ram, therefore check our online docs to ensure you are including the correct header syntax.
Photo of Ram Singh

Ram Singh

  • 110 Points 100 badge 2x thumb
Hi Jason,

I tried to use the Auth_code for Grant_Type, but still, it's throwing me same error. 
Photo of Jason Hollis

Jason Hollis, Head of Product

  • 10,278 Points 10k badge 2x thumb
Hi Ram, so your grant type has been changed to Resource Owner as requested. Check our docs to make sure you are passing the correct header.
Photo of Ram Singh

Ram Singh

  • 110 Points 100 badge 2x thumb
Hi Jason,

Could you please share the link where you have specified this thing for Resource Owner.
Photo of Simon Hutchinson

Simon Hutchinson, Employee

  • 2,502 Points 2k badge 2x thumb
Hi Ram

Now that Jason ha changed the identity server credentials, your grant_type is password as per your above code

Thanks

Simon H
Reckon API 
Photo of Jason Hollis

Jason Hollis, Head of Product

  • 10,278 Points 10k badge 2x thumb
Photo of Jason Hollis

Jason Hollis, Head of Product

  • 10,278 Points 10k badge 2x thumb
Look at Resource Owner. There are also links to a site that explains the grant types for OAuth2 so please ensure resource owner is for you. If not let us know. 
Photo of Jason Hollis

Jason Hollis, Head of Product

  • 10,278 Points 10k badge 2x thumb
Here is that link I mentioned above: https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2

Our default Grant Type is Authorization Code and we do not offer any others unless you provide your specific use case (which you did in your email to us).

Other available are Implicit and Resource Owner. 

The above site gives good examples on what each is best used for.