I can receive an email when a user logs in through apps.com.
My problem is that I cannot get the first and last name. here is a sample code from intuit, I tried adding 'namePerson / first' and 'namePerson / last' to the required attribute, but that doesn't help.
The codes I use are for example intuit https://github.com/IntuitDeveloper/SampleApp-PHP-for-OpenId-OAuth-V3APICalls/blob/master/PHPSample/index.php
<?php
ob_start();
require_once("config.php");
require_once("CSS Styles/StyleElements.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<h3>IPP PHP Sample App</h3>
<title>IPP PHP sample</title>
<script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
<script>
var parser = document.createElement('a');
parser.href = document.url;
intuit.ipp.anywhere.setup({
menuProxy: '',
grantUrl: 'http://'+parser.hostname+'/sampleqboapp/PHPSample/oauth.php?start=t'
});
</script>
</head>
<body>
<?php
echo '<div> Please refer to the <a target="_blank" href="http://localhost/PHPSample/ReadMe.htm">Read Me</a> page for detailed instructions and information regarding this sample </div><br />';
require 'lightopenid-lightopenid/openid.php';
try {
$openid = new LightOpenID('localhost');
if(!$openid->mode) {
echo '<div> This sample uses PHP 5.6.3 and Intuit PHP SDK version v3-php-sdk-2.2.0-RC
</div><br />';
echo '<div> To be listed on QuickBooks Apps.com, any app must implement OpenID for user authentication. This sample uses LightOpenID library located at
<a target="_blank" href="https://gitorious.org/lightopenid"> https://gitorious.org/lightopenid </a><br />
</div><br />';
$openid->identity = "https://openid.intuit.com/Identity-jameshwart";
$openid->required = array(
'namePerson/friendly',
'contact/email' ,
'contact/country/home',
'namePerson',
'namePerson/first',
'namePerson/last',
'pref/language',
);
header('Location: ' . $openid->authUrl());
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
echo '<pre>';
print_r($openid);
print_r($openid->getAttributes());
echo '</pre>';
echo '<br /><a href="javascript:void(0)" onclick="return intuit.ipp.anywhere.logout(function () { window.location.href = \'http://localhost/sampleqboapp/PHPSample/index.php\'; });">Sign Out</a>';
require_once('../v3-php-sdk-2.2.0-RC/config.php');
require_once(PATH_SDK_ROOT . 'Core/ServiceContext.php');
require_once(PATH_SDK_ROOT . 'DataService/DataService.php');
require_once(PATH_SDK_ROOT . 'PlatformService/PlatformService.php');
require_once(PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php');
error_reporting(E_ERROR | E_PARSE);
$tk = $_SESSION['token'];
if(!isset($_SESSION['token'])){
echo "<h3>You are not currently authenticated!</h3>";
echo '<div> This sample uses the Pecl Oauth library for OAuth. </div> <br />
<div> If not done already, please download the Oauth package from
<a target="_blank" href="http://pecl.php.net/package/oauth"> http://pecl.php.net/package/oauth </a> and follow the instructions given
<a target="_blank" href="http://pecl.php.net/package/oauth"> here </a> for installing the Oauth module.
</div><br />
<div> Add the OAuth Consumer Key and OAuth Consumer Secret of your application to config.php file </div> </br>
<div> Click on the button below to connect this app to QuickBooks
</div>';
echo "<br /> <ipp:connectToIntuit></ipp:connectToIntuit><br />";
} else {
echo "<h3>You are currently authenticated!</h3>";
$token = unserialize($_SESSION['token']);
echo "If not already done, please make sure that you set the below variables in the app.config file, before proceeding further! <br />";
echo "<br />";
echo "realm ID: ". $_SESSION['realmId'] . "<br />";
echo "oauth token: ". $token['oauth_token'] . "<br />";
echo "oauth secret: ". $token['oauth_token_secret'] . "<br />";
echo "<br />";
echo "<button class='myButton' title='App Home Page' onclick='myFunction($value)'>Go to the app</button>";
echo ' ';
echo "<button class='myButton' title='Disconnect your app from QBO' onclick='Disconnect($value)'>Disconnect the app</button>";
echo ' ';
echo "<button class='myButton' title='Regenerate the tokens within 30 days prior to token expiration' onclick='Reconnect($value)'>Reconnect the app</button>";
echo "<br />";
echo "<br />";
echo "<br />";
echo '<div> <small> <u> Note:</u> Configuring the Oauth tokens manually in app.config file is only for demonstartion purpose in this sample app. In real time production app, save the oath_token, oath_token_secret, and realmId in a persistent storage, associating them with the user who is currently authorizing access. Your app needs these values for subsequent requests to Quickbooks Data Services. Be sure to encrypt the access token and access token secret before saving them in persistent storage.<br />
Please refer to this <a target="_blank" href="https://developer.intuit.com/docs/0050_quickbooks_api/0020_authentication_and_authorization/connect_from_within_your_app"> link </a>for implementing oauth in your app. </small></div> <br />';
}
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
ob_end_flush();
?>
<script>
function myFunction(parameter){
window.location.href = "http://localhost/PHPSample/SampleAppHomePage.php";
}
function Disconnect(parameter){
window.location.href = "http://localhost/PHPSample/Disconnect.php";
}
function Reconnect(parameter){
window.location.href = "http://localhost/PHPSample/Reconnect.php";
}
</script>
</body>
</html>
Can someone point out what I missed?
source
share