asol Posted June 3, 2019 Share Posted June 3, 2019 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. 0 Quote Link to comment Share on other sites More sharing options...
xXCalleManXx Posted November 22, 2019 Share Posted November 22, 2019 @asol did you ever find a solution for this? 0 Quote Link to comment Share on other sites More sharing options...
asol Posted November 22, 2019 Author Share Posted November 22, 2019 I actually found a better article in the documentations which helped me figure it out: https://docs.whmcs.com/AutoAuth 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.