Quickbooks Online Error PHP - php

When I attempt to connect to QBO via the Consolibyte package I downloaded I get an error.
Error Code: internal_error
Message: Error getting application from request token
You can contact us for further assistance. Error
Id:ixnkryec2iu513ef45f3f5xv-12940655
I have set up the config.php file as directed in the instructions and even got to the point of authorizing the application with Quickbooks but now when I navigate to the page it indicates that I am not logged in and when I click the "Connect to QuickBooks" button on the index.php page I get the error above. I'm not familiar enough with the process to know where to start troubleshooting this problem and any help would be greatly appreciated.
Link: http://production.technology-architects.com/unleashed_new/quickbook/docs/partner_platform/example_app_ipp_v3/
example_app_ipp_v3/config.php code
require_once dirname(__FILE__) . '/../../../QuickBooks.php';
$token = 'f5ddd229b1d19b4153b8218b08b97897050f';
$oauth_consumer_key = 'qyprdYvvyNLq1om6FSw0xLebctZEAz';
$oauth_consumer_secret = 'KCLYZRgZ4LnHUB35AzvylxnH6c8CDCyjhva8I9Gp';
$sandbox = true; // When you're using development tokens
$quickbooks_oauth_url = 'http://production.technology-architects.com/unleashed_new/quickbook/docs/partner_platform/example_app_ipp_v3/oauth.php';
$quickbooks_success_url = 'http://production.technology-architects.com/unleashed_new/quickbook/docs/partner_platform/example_app_ipp_v3/success.php';
$quickbooks_menu_url = 'http://production.technology-architects.com/unleashed_new/quickbook/docs/partner_platform/example_app_ipp_v3/menu.php';
$dsn = 'mysqli://myusername:mypassword#localhost/databasename';
$encryption_key = 'bcde1234';
$the_username = 'DO_NOT_CHANGE_MEddd';
$the_tenant = 'sdfaswrqwerqwr';
if (!QuickBooks_Utilities::initialized($dsn)){
QuickBooks_Utilities::initialize($dsn);
}
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret, $quickbooks_oauth_url, $quickbooks_success_url);
if ($IntuitAnywhere->check($the_username, $the_tenant) and $IntuitAnywhere->test($the_username, $the_tenant)){
$quickbooks_is_connected = true;
$IPP = new QuickBooks_IPP($dsn);
$creds = $IntuitAnywhere->load($the_username, $the_tenant);
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH,
$the_username,
$creds);
if ($sandbox){
$IPP->sandbox(true);
}
$realm = $creds['qb_realm'];
$Context = $IPP->context();
$CompanyInfoService = new QuickBooks_IPP_Service_CompanyInfo();
$quickbooks_CompanyInfo = $CompanyInfoService->get($Context, $realm);
} else {
$quickbooks_is_connected = false;
}

None of the tokens or OAuth credentials you have in your code match what you have in the screenshot.
Fix your tokens and OAuth values.
$token = 'f5ddd229b1d19b4153b8218b08b97897050f';
$oauth_consumer_key = 'qyprdYvvyNLq1om6FSw0xLebctZEAz';
$oauth_consumer_secret = 'KCLYZRgZ4LnHUB35AzvylxnH6c8CDCyjhva8I9Gp';

Related

openid connect to identify server in php

I'm using https://github.com/jumbojett/OpenID-Connect-PHP this library to auth an user from identify server 4.
I'm trying to connect to identify server which has this settings
Scope : offline_access
Response type: code id_token
DefaultScheme = “Cookie”
Error I'm getting:
Sorry, there was an error : unauthorized_client
Invalid grant type for client
My code
$issuer = 'issuer';
$cid = 'clientid';
$secret = 'clientsecret';
$oidc = new Jumbojett\OpenIDConnectClient($issuer, $cid, $secret);
$oidc->addScope(array('openid', 'offline_access'));
$oidc->authenticate();
$oidc->requestUserInfo('sub');
$user = $oidc->requestUserInfo();
session_start();
$_SESSION['user'] = $user;

Making the DocuSign API transition from sandbox to live

I integrated the PHP API for DocuSign by creating a sandbox account, downloading the php sample and placing the correct credentials in, testing (which worked as expected) and then ran through the live process of 20 transactions, having an enterprise account, etc. All was approved and everything seemed in order according to the admin panel, but making the changes documented in the go live docs just results in a server 500 error. Anyone else experienced this? Maybe some part of the live transition escaped me?
The code below should return login info:
// DocuSign account credentials & Integrator Key
$username = "someemail#somewhere.com"; //or the account string
$password = "xxxxx";
$integrator_key = "abc-123";
$host = "https://demo.docusign.net/restapi";
// create a new DocuSign configuration and assign host and header(s)
$config = new DocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
/////////////////////////////////////////////////////////////////////////
// STEP 1: Login() API
/////////////////////////////////////////////////////////////////////////
// instantiate a new docusign api client
$apiClient = new DocuSign\eSign\ApiClient($config);
// we will first make the Login() call which exists in the AuthenticationApi...
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);
// optional login parameters
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
// call the login() API
$loginInformation = $authenticationApi->login($options);
// parse the login results
if(isset($loginInformation) && count($loginInformation) > 0)
{
// note: defaulting to first account found, user might be a
// member of multiple accounts
$loginAccount = $loginInformation->getLoginAccounts()[0];
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
echo "Account ID = $accountId\n";
// works as expected
}
}
}
Now, try the same thing using the live URL and credentials as suggested by the go live docs here:
$username = "live-user-account"; <--- live username or email
$password = "xxxxx"; <--- live pw
$integrator_key = "abc-123"; <--- same integrator key
$host = "https://www.docusign.net/restapi/v2/login_information"; <--- live URL
All I get is a server 500 error. I tried with just https://www.docusign.net/restapi and same thing. Server 500 error.
Is there some part of the go live process I overlooked?
Side note - this is attached to an enterprise level account
Ok so get ready for an idiotic ride....
Another stack overflow post answers this here, but I will skip to the actual answer found here
Basically - you have to redefine the $apiClient variable by calling back the api with returned info...
$username = "xxx-xx-xxxx"; <--- your username string or email
$password = "xxxxx"; <--- your password
$integrator_key = "aaa-bbb-ccc"; <--- your integrator key
$host = "https://www.docusign.net/restapi"; <--- LIVE url
// create a new DocuSign configuration and assign host and header(s)
$config = new DocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
/////////////////////////////////////////////////////////////////////////
// STEP 1: Login() API
/////////////////////////////////////////////////////////////////////////
// instantiate a new docusign api client
$apiClient = new DocuSign\eSign\ApiClient($config);
// we will first make the Login() call which exists in the AuthenticationApi...
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);
// optional login parameters
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
// call the login() API
$loginInformation = $authenticationApi->login($options);
// parse the login results
if(isset($loginInformation) && count($loginInformation) > 0)
{
// note: defaulting to first account found, user might be a
// member of multiple accounts
$loginAccount = $loginInformation->getLoginAccounts()[0];
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
// HERE is where we all go wrong
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object and then re-call the api client
$config->setHost($host);
$apiClient = new DocuSign\eSign\ApiClient($config);
if(!empty($accountId))
{
//echo "Account ID = $accountId\n";
}
}
}
Then poof, your envelope calls will magically work after that...
This is one FUGLY implementation of a sandbox -> live process. We got some great PHP sample for sandbox but then no connected real world examples of how you have to change things around in the live environment. Yes, we get that live can differ, but just leave this one small piece commented in the php sample and say "when going live, uncomment this" ... Literally nothing else in the code is different other than the login creds.
simple as that.
It kind of makes the sandbox pointless since I now have to re-test everything to make sure this live code is stable.
Thank you support for trying.

How to integrate Google Plus OAuth API with Codeigniter?

I'm trying to build a simple project in which the google plus profile data will be saved or will get updated into the database. I'm unable to figure the way out of invalid character URI problem. I'm getting invalid character URI as response from google.
How can I solve this problem of invalid URI?
I have attached the image of the error at the end of this post.
Login Controller class code is:
public function index() {
// Include the google api php libraries
include_once APPPATH."libraries/google-api-php-client/Google_Client.php";
include_once APPPATH."libraries/google-api-php-client/contrib/Google_Oauth2Service.php";
// Google Project API Credentials
$clientId = 'My Client ID';
$clientSecret = 'My Secret here';
$redirectUrl = 'https://example.com/index.php?login/index/';
// Google Client Configuration
$gClient = new Google_Client();
$gClient->setApplicationName('Login to Application');
$gClient->setClientId($clientId);
$gClient->setClientSecret($clientSecret);
$gClient->setRedirectUri($redirectUrl);
$google_oauthV2 = new Google_Oauth2Service($gClient);
if (isset($_REQUEST['code'])) {
$gClient->authenticate();
$this->session->set_userdata('token', $gClient->getAccessToken());
redirect($redirectUrl);
}
$token = $this->session->userdata('token');
if (!empty($token)) {
$gClient->setAccessToken($token);
}
if ($gClient->getAccessToken()) {
$userProfile = $google_oauthV2->userinfo->get();
// Preparing data for database insertion
$userData['oauth_provider'] = 'google';
$userData['oauth_uid'] = $userProfile['id'];
$userData['first_name'] = $userProfile['given_name'];
$userData['last_name'] = $userProfile['family_name'];
$userData['email'] = $userProfile['email'];
$userData['gender'] = $userProfile['gender'];
$userData['locale'] = $userProfile['locale'];
$userData['profile_url'] = $userProfile['link'];
$userData['picture_url'] = $userProfile['picture'];
// Insert or update user data
$userID = $this->user->checkUser($userData);
if(!empty($userID)){
$data['userData'] = $userData;
$this->session->set_userdata('userData',$userData);
} else {
$data['userData'] = array();
}
} else {
$data['authUrl'] = $gClient->createAuthUrl();
}
$this->load->view('backend/login',$data);
}
The image of the error :
I am unable to tackle the problem. Please suggest me how can I avoid this.

How do you get user OAuth for the Tumblr API in PHP?

Using the default Tumblr v2 API, I'm able to connect to my application, and retrieve posts from my own account. However, I'd like users to be able to connect their own accounts. I've tried to figure this out but I'm not entirely sure how to use OAuth (im using this class). How is this done?
The code I'm using to retrieve dashboard posts is:
$consumerKey = 'xxx';
$consumerSecret = 'xxx';
$tumblr = new Tumblr\API\Client(
$consumerKey,
$consumerSecret
);
var_dump( $tumblr->getDashboardPosts() ); // using var_dump for testing purposes only
This code works, but it's only returning the code for my PERSONAL account.
I figured it out, thanks to Github user seejohnrun.
require_once 'include/util.php';
$consumerKey = 'XXX';
$consumerSecret = 'XXX';
$client = new Tumblr\API\Client($consumerKey, $consumerSecret);
$requestHandler = $client->getRequestHandler();
$requestHandler->setBaseUrl('https://www.tumblr.com/');
// If we are visiting the first time
if (!$_GET['oauth_verifier']) {
// grab the oauth token
$resp = $requestHandler->request('POST', 'oauth/request_token', array());
$out = $result = $resp->body;
$data = array();
parse_str($out, $data);
// tell the user where to go
echo ' GO ';
$_SESSION['t']=$data['oauth_token'];
$_SESSION['s']=$data['oauth_token_secret'];
} else {
$verifier = $_GET['oauth_verifier'];
// use the stored tokens
$client->setToken($_SESSION['t'], $_SESSION['s']);
// to grab the access tokens
$resp = $requestHandler->request('POST', 'oauth/access_token', array('oauth_verifier' => $verifier));
$out = $result = $resp->body;
$data = array();
parse_str($out, $data);
// and print out our new keys we got back
$token = $data['oauth_token'];
$secret = $data['oauth_token_secret'];
echo "token: " . $token . "<br/>secret: " . $secret;
// and prove we're in the money
$client = new Tumblr\API\Client($consumerKey, $consumerSecret, $token, $secret);
$info = $client->getUserInfo();
echo "<br/><br/>congrats " . $info->user->name . "!";
}

Twitter access to resource error after first connection

I successfully setup twitteroauth and posted a message. Now, when I try to post again, and every time AFTER THE FIRST successful message post, I get an error Your credentials do not allow access to this resource. (code 220);
Here's my code:';
$message = 'Test';
$apiKey = Ranger_Application_Util::getConfig('twitter_app_api_key');
$apiSecret = Ranger_Application_Util::getConfig('twitter_app_api_secret');
$consumerToken = Ranger_Application_Util::getStorageData('twitter_oauth_token');
$consumerSecret = Ranger_Application_Util::getStorageData('twitter_oauth_secret');
$twitterOauthVerifier = Ranger_Application_Util::getStorageData('twitter_oauth_verifier');
$_SESSIOM['oauth_token'] = $consumerToken;
$_SESSION['oauth_token_secret'] = $consumerSecret;
require_once 'twitter/twitteroauth.php';
$connection = new TwitterOAuth($apiKey,$apiSecret,$consumerToken,$consumerSecret);
$connection->host = "https://api.twitter.com/1.1/";
$accessToken = $connection->getAccessToken($twitterOauthVerifier);
$_SESSION['access_token'] = $accessToken;
$parameters = array('status' => $message);
$status = $connection->post('statuses/update',$parameters);
Core::dump($status);
die();
The data I retrieve from getStorageData is values stored in the database that pertain to that specific user.
Unless you are storing the information from $accessToken to your database in a piece of code you have not posted, I believe the issue may be that you are getting the access token after your initial connection, but not using the permanent access information from the access token when trying to post to the connection. So any future requests will not be using the permanent credentials and are therefore rejected. Try something like this:
$message = 'Test';
$apiKey = Ranger_Application_Util::getConfig('twitter_app_api_key');
$apiSecret = Ranger_Application_Util::getConfig('twitter_app_api_secret');
$twitterOauthVerifier = Ranger_Application_Util::getStorageData('twitter_oauth_verifier');
require_once 'twitter/twitteroauth.php';
$hasAccessToken = (
array_key_exists('oauth_token', $_SESSION) &&
array_key_exists('oauth_token_secret', $_SESSION));
if ($hasAccessToken)
{
$consumerToken = $_SESSION['oauth_token'];
$consumerSecret = $_SESSION['oauth_token_secret'];
}
else
{
$consumerToken = Ranger_Application_Util::getStorageData('twitter_oauth_token');
$consumerSecret = Ranger_Application_Util::getStorageData('twitter_oauth_secret');
$connection = new TwitterOAuth($apiKey, $apiSecret, $consumerToken, $consumerSecret);
$connection->host = "https://api.twitter.com/1.1/";
$accessToken = $connection->getAccessToken($twitterOauthVerifier);
$consumerToken = $accessToken['oauth_token'];
$consumerSecret = $accessToken['oauth_token_secret'];
$_SESSION['oauth_token'] = $consumerToken;
$_SESSION['oauth_token_secret'] = $consumerSecret;
}
$connection = new TwitterOAuth($apiKey, $apiSecret, $consumerToken, $consumerSecret);
$connection->host = "https://api.twitter.com/1.1/";
$parameters = array('status' => $message);
$status = $connection->post('statuses/update', $parameters);
Core::dump($status);
die();
You may want to store the oauth token information in your database after receiving it from getAccessToken() rather than using sessions. Maybe you have a method like Ranger_Application_Util::setStorageData('twitter_oauth_token', $consumerToken)?
This
$_SESSIOM['oauth_token'] = $consumerToken;
^
should be
$_SESSION['oauth_token'] = $consumerToken;

Categories