Jump to content

Authentcation - convert auth code into auth token


 Share

Recommended Posts

Hello,

Using Sage Cloud Accounting and a Sage Developers account.  I was able to connect via postman no problem.  However, in my application, I cannot convert my auth code into the auth token.  I always get {"$severity":"error","$dataCode":"DataParsingError","$message":"The data you sent could not be processed.","$source":"Proxy"} as a response.

I have tried posting to https://oauth.accounting.sage.com/token using every method imaginable (with the parameters as a string in the url, within the header, and within the body of the post request. Same response every time.

I am wondering if my initial auth code is incorrect.  On return from the call back, I always get an auth code that looks something like this: US/ccaf9694-ea52-49be-a334-eecfd2066cd5. However, the examples always show something with way less characters: 12axxxxxxxxxxxxf7d. 

Am I using the correct auth code? Any help would be amazing!

 

Thank you,

A simple programmer

Edited by Joe Lanza
Link to comment
Share on other sites

Hi Joe, thank you for your question.


The auth code looks to be correct, can you provide us with the POST request you are making to exchange the auth code https://oauth.accounting.sage.com/token. Please remove your client_id and client_secret and ensure the redirect URI you are using in the request is identical to that you have registered in https://developerselfservice.sageone.com/session/new.

Thanks

Mark

 

Link to comment
Share on other sites

Thank you for your reply.

Our application uses perl. I've tried this POST so many different ways now.

my $req = HTTP::Request->new(POST => https://oauth.accounting.sage.com/token);

$req->header('Content-type' => 'application/x-www-form-urlencoded');

$req->content(
     [

     client_id          => $client_id,
     client_secret => $client_secret,
     grant_type      => authorization_code,
     code                   =>   $authcode,
     redirect_uri    => $redirect

]

);

the $req->content is the Body of the POST.

I've also tried putting these required values in the initial POST request: https://oauth.accounting.sage.com/token?client_id=$client_id&client_secret=$client_secret&code=$authcode&grant_type=authorization_code&redirect_uri=$redirect

I've also tried putting these required parameters in the header.

Can you provide a CURL example of this POST request and how the required parameters are supposed to be passed?  The documentation is a little vague on this:

POST https://oauth.accounting.sage.com/token
Required parameters
client_id Your app Client ID. You can get this value from the App Details.
client_secret Your app Client Secret. You can get this value from the App Details.
code The authorization code provided in the response from the previous step.
grant_type This must be authorization_code.
redirect_uri Your app callback URL. You must provide this value exactly as configured in the App Details, you must not add any additional params.

Thank you!

Link to comment
Share on other sites

  • Administrators

Hi Joe,

Specifying the params in the body is correct, and all looks good to me but can you also include another header 'Accept': 'application/json' too and see if that helps at all? 

 

Ben

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...