Jump to content

whmcs automatic login using single sign on to invoice detail page


imes

Recommended Posts

Hello,

I was wondering if anyone could lend us a hand.
We are trying to redirect our customers from our website to the client area on WHMCS using OAuth's single sign-on API, but with little success.Here's what we wrote:

  Quote

 

<?php
$id = 'XXXX';
$pass = 'XXXX';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://dev-wh.asolutions.co.jp/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query(
        array(
            'action' => 'CreateOAuthCredential',
            // See https://developers.whmcs.com/api/authentication
            'username' => $id,
            'password' => md5($pass),
            'grantType' => 'single_sign_on',
            'scope' => 'clientarea:sso clientarea:billing_info clientarea:announcements',
            'serviceId' => '1',
            'description' => 'Billing and Announcements SSO',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);

$error = curl_error($ch);
curl_close($ch);

echo $error;
var_dump($response);
echo "TEST";
?>

 

And what we got back:
 

  Quote

string(681) "{"result":"error","message":"SQLSTATE[23000]: Integrity constraint violation: 1048 Column \u0027user_id\u0027 cannot be null (SQL: insert into `tbloauthserver_clients` (`identifier`, `secret`, `user_id`, `service_id`, `rsa_key_pair_id`, `name`, `description`, `logo_uri`, `redirect_uri`, `grant_types`, `updated_at`, `created_at`) values (ASSIST-SOLUTIONS.MrNEbiWqo7UZc6vPjby6Rw==, 4ae7f87da5c1cf110bd5466ab566a495cf71897c153e79522ce289f4f657b5fc0a2d396a949b927dbe0c4d98a1de0e4bdd7ee704f385c5d819d6c05ae079c0d47e0a02ef90cb57eafae2e4f2822f0ae4e6cdcdce9265bb1ca7f270a41bd990be, , 1, 0, , Billing and Announcements SSO, , , single_sign_on, 2019-05-30 05:48:33, 2019-05-30 05:48:33))"}"

I've looked at the documentation (https://docs.whmcs.com/WHMCS_Single_Sign-On_Developer_Guide) and also opened a ticket with WHMCS support but I have yet to understand how I can achieve the single sign-on that I am looking for.

If anyone who is experienced in this could share us a sample script of yours that went through, or even just point out what I might be doing wrong, it would be highly appreciated.

I don't want use AutoAuth because it will be deactivated on version 8.1

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.

Guest
Reply to this topic...

×   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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated