How can I send someone a document for signing using Adobe EchoSign API v5? For API version 5, I could only find an example using Java. But I need it in PHP. If I use any earlier version it requires an "API key", but in the current version of API, I can't find my API key. I can't even find any sample code in PHP.
There's no longer an API key in the current version as it now uses "Access Token". This is what I did on my PHP application.
Store the Application ID and Client Secret and use it for requesting access token.
If request is successful, store both access token and refresh token and the timestamp in your database.
Access token will expire in 1 hour so you have to check if it already expires.
If access token has expired. Request for refresh token and it should return a new access token.
Replace the access token you stored with the new one you receive and regain access to the API.
I took me a while but I got it working, I hope it helps others, after installing with composer (https://github.com/kevinem/adobe-sign-php/) yo need to create your sandbox page, for me was a index.php in /vendor/kevinem/adobe-sign-php/ then you need to include 2 classes AdobeSign and Psr7 in my case, because I need to upload 2 documments.
require "../../../vendor/autoload.php";
use KevinEm\AdobeSign\AdobeSign;
use GuzzleHttp\Psr7;
this is how I configure my $provider, the call backurl must be the same as the one in the backend of adobe and I changed manually the data center in AdobeSign.php
$provider = new KevinEm\OAuth2\Client\AdobeSign([
'clientId' => 'YOUR_APP_ID',
'clientSecret' => 'YOUR_APP_SECRET',
'redirectUri' => 'YOUR_BACK_URL',
'dataCenter' => 'secure.na2',
'scope' => ['user_login:self',
'agreement_write:self',
'widget_write:self',
'library_write:self',
'agreement_send:self'
]
]);
Then u need to create an array with the URL of all your .pdf documents. my is call $archivos.
$accessToken = $adobeSign->getAccessToken($_GET['code']);
$adobeSign->setAccessToken($accessToken->getToken());
$todosDoc = array();
foreach ($archivos as $doc) {
$file_path = __DIR__.$doc;
$file_stream = Psr7\FnStream::decorate(Psr7\stream_for(file_get_contents($file_path)), [
'getMetadata' => function() use ($file_path) {
return $file_path;
}
]);
$multipart_stream = new Psr7\MultipartStream([
[
'name' => 'File',
'contents' => $file_stream
]
]);
$transient_document = $adobeSign->uploadTransientDocument($multipart_stream);
array_push($todosDoc, $transient_document);
}
$adobeSign->createAgreement([
'documentCreationInfo' => [
'fileInfos' => $todosDoc,
'name' => 'My Document Test',
'signatureType' => 'ESIGN',
'recipientSetInfos' => [
'recipientSetMemberInfos' => [
'email' => 'orlando#yoursigner.com'
],
'recipientSetRole' => [
'SIGNER'
]
],
'mergeFieldInfo' => [
[
'fieldName' => 'Name',
'defaultValue' => 'John Doe'
]
],
'signatureFlow' => 'SENDER_SIGNATURE_NOT_REQUIRED'
]
]);
Adobe Sign has changed its authentication process and instead of using "API key", it now uses "Access-Token" which is more secure.
You can use any PHP based third part rest API client library for the Adobe Sign API calls until Adobe Sign itself provides the SDK for PHP.
Adobe eSign is now using oAuth for authentication, and there are a lot of different libraries for different languag
Related
I have to implement bigcommerce API integration with PHP
and I am trying to use the official library from https://github.com/bigcommerce/bigcommerce-api-php
and I am not even able to start step 1 here.
Issues:
Basic Auth method
Bigcommerce::configure(array(
'store_url' => 'https://store.mybigcommerce.com',
'username' => 'admin',
'api_key' => 'd81aada4xc34xx3e18f0xxxx7f36ca'
));
So the question here is how to get a username? bigcommerece user only created using email address so how to get username here?
OAuth method
In order to obtain the auth_token you would consume Bigcommerce::getAuthToken method
$object = new \stdClass();
$object->client_id = 'xxxxxx';
$object->client_secret = 'xxxxx;
$object->redirect_uri = 'https://app.com/redirect';
$object->code = $request->get('code');
$object->context = $request->get('context');
$object->scope = $request->get('scope');
$authTokenResponse = Bigcommerce::getAuthToken($object);
Bigcommerce::configure(array(
'client_id' => 'xxxxxxxx',
'auth_token' => $authTokenResponse->access_token,
'store_hash' => 'xxxxxxx'
));
here the question is what is the $request variable? also, redirect_uri is the bigcommerce store URL or my site URL?
Please can anyone help to get started with this?
It's because that library is a bit out of date with how api accounts are managed. For the basic auth you would use "legacy accounts". You can just use the OAuth method without the oAuth flow (assuming you're trying to connect to your own store, not create an app).
Just the following will work:
Bigcommerce::configure(array(
'client_id' => 'client-id',
'auth_token' => 'access-token',
'store_hash' => 'store-hash'
));
You should get these after creating a user in the dashboard (you can ignore the secret for this use case)
I am trying to establish connection between my Application and DocuSign Sandbox.
I'am using JWT Authorization.
I have Integration key with RSA private key generated.
I have user to impersonate with GUID and consent aquired
I call https://account-d.docusign.com/oauth/token with proper data which response with success and give me back Access token
Everything works well until this moment.
I've downloaded library for PHP "docusign/esign-client"
and used this fragment of code:
$recipientId = uniqid(5);
$clientUserId = uniqid(5);
$document = new Document([
'document_base64' => $base64FileContent,
'name' => 'Application Form',
'file_extension' => 'pdf',
'document_id' => '1'
]);
$signer = new Signer([
'email' => $email,
'name' => $name,
'recipient_id' => $recipientId,
'routing_order' => "1",
'client_user_id' => $clientUserId,
]);
$signHere = new SignHere([
'document_id' => '1', 'page_number' => '3', 'recipient_id' => $recipientId,
'tab_label' => 'SignHereTab', 'x_position' => '195', 'y_position' => '147'
]);
$signer->setTabs(new Tabs(['sign_here_tabs' => [$signHere]]));
$envelopeDefinition = new EnvelopeDefinition([
'email_subject' => "Please sign this document",
'documents' => [$document],
'recipients' => new Recipients(['signers' => [$signer]]),
'status' => "sent"
]);
$config = new Configuration();
$config->setHost('https://demo.docusign.net/restapi');
$config->addDefaultHeader("Authorization", "Bearer " . $accessToken);
$config->setAccessToken($accessToken);
$apiClient = new ApiClient($config);
$envelopeApi = new EnvelopesApi($apiClient);
$results = $envelopeApi->createEnvelope($integrationKey, $envelopeDefinition);
The result is an error (400) comes from API with info:
PARTNER_AUTHENTICATION_FAILED
The specified Integrator Key was not found or is disabled. Invalid account specified for user.
It says integration key is wrong but few lines before I used this integration key to generate Access Token with success.
Do you have any idea whats is going wrong ?
Before JWT integrations, I was using different integration key and access token from OAuth Token Generator and it worked fine (this previous key didn't have RSA generated)
Could you guys help me with that issue ?
If any more informations could help to find a solution just let me know and I will update my post.
Thanks for help.
The issue is in this line
$results = $envelopeApi->createEnvelope($integrationKey, $envelopeDefinition);
The first parameter of the createEnvelope method should be the Account ID, not the integrator key.
After you receive the access token, you can make a UserInfo call and pull the account ID from that.
i need create and publish products in ebay with php , i find this sdk, but this not work for me, some have an code or example for this?
https://github.com/davidtsadler/ebay-sdk-php
in this sdk i get this error
Cannot read credentials from /.ebay_sdk/credentials in C:\wamp64\www\ebay\vendor\dts\ebay-sdk-php\src\Credentials\CredentialsProvider.php on line 132
but i changue the credentials in CredentialsProvider.php
I am using the same SDK (and it's amazing how awesome it is). The guy who created this SDK also provides some examples. You can find them all here. In the Trading folder, you will find 6 (I think) different examples of how to list an item using this SDK.
If you still have problems with the credentials, you could add the credentials manually (but I don't recommend it). Instead of using
$service = new Services\TradingService([
'credentials' => $config['sandbox']['credentials'],
'sandbox' => true,
'siteId' => $siteId
]);
you could use
$service = new Services\TradingService([
'credentials' => [
'devId' => 'YOUR_DEV_ID',
'appId' => 'YOUR_APP_ID',
'certId' => 'YOUR_CERT_ID',
],
'siteId' => EBAY_SITE_ID,
'sandbox' => true, // or false, up to you
'token' => 'YOUR_TOKEN'
]);
I'm integrating with a affiliate platform for a client which provides an oAuth2 API, don't usually do massive amounts of work with oAuth2.
I've decided for my client, I'll use the PHP Leagues oAuth2 package: https://github.com/thephpleague/oauth2-client
Anyway, I've got an accessToken no problem! using the following:
$provider = new GenericProvider([
'clientId' => $this->config->affiliates->rakuten->clientId,
'clientSecret' => $this->config->affiliates->rakuten->clientSecret,
'redirectUri' => 'http://www.newintoday.com/',
'urlAuthorize' => 'https://api.rakutenmarketing.com/token', // Ignore
'urlAccessToken' => 'https://api.rakutenmarketing.com/token',
'urlResourceOwnerDetails' => 'https://api.rakutenmarketing.com/' // Ignore
]);
try {
// Try to get an access token using the resource owner password credentials grant.
$accessToken = $provider->getAccessToken('password', [
'username' => $this->config->affiliates->rakuten->username,
'password' => $this->config->affiliates->rakuten->password,
'scope' => $this->config->affiliates->rakuten->publisherId,
]);
$productSearchApiBaseUri = 'https://api.rakutenmarketing.com/productsearch/1.0';
$request = $provider->getAuthenticatedRequest('GET', $productSearchApiBaseUri, $accessToken, [
'body' => '?keyword=shirt',
]);
\Utils::dump($provider->getResponse($request));
} catch (IdentityProviderException $e) {
echo $e->getMessage();
}
My question is once we have the accessToken what do we use in it to make the request, I followed through the code and came up with the above but the API responds saying that the keyword is not specified? Is
$request = $provider->getAuthenticatedRequest('GET', $productSearchApiBaseUri, $accessToken, [
'body' => 'keyword=shirt',
]);
The correct way to provide it with a GET variable?
Thanks in advance.
Realised I could simply include the get vars in the URI alla:
$productSearchApiBaseUri = 'https://api.rakutenmarketing.com/productsearch/1.0?keyword=shirt';
I've searched far and wide and have come up with little to nothing on this problem. I've made a module for my Yii app that crawls my website and gathers links to generate a sitemap, I've even made it so that it can run on a cron.
Now I've hit the wall with Google Webmaster Tools API and it's lack of information on how to implement it with OAuth2 for sitemap submission.
Every time I've tried to submit the sitemap I got this response back:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
I would very much appreciate any pointers in any direction.
Maybe this extension can help you:
http://www.yiiframework.com/extension/jgoogleapi/
I'm not sure which is the API for sitemaps and what are its methods but that extension would help you Login to google in "Service" mode that won't need your browser to interact with the login.
You should also before create your application in Google console and then create a service account user type for it.
A paste of my config file when using this extension with Google Analytics:
<?php
/*
* How to obtain a Service Account:
* https://developers.google.com/accounts/docs/OAuth2ServiceAccount
*
*
* (403) User does not have any Google Analytics account.
* http://stackoverflow.com/a/13167988/115050
*
*
*/
return array(
'class' => 'ext.JGoogleAPI.JGoogleAPI',
//Default authentication type to be used by the extension
'defaultAuthenticationType'=>'serviceAPI',
//Account type Authentication data
'serviceAPI' => array(
'clientId' => '...',
'clientEmail' => '...',
'keyFilePath' => dirname(__FILE__).'/../extensions/JGoogleAPI/keys/Analytics-a0e8e345f273.p12',
),
/*
//You can define one of the authentication types or both (for a Service Account or Web Application Account)
webAppAPI = array(
'clientId' => 'YOUR_WEB_APPLICATION_CLIENT_ID',
'clientEmail' => 'YOUR_WEB_APPLICATION_CLIENT_EMAIL',
'clientSecret' => 'YOUR_WEB_APPLICATION_CLIENT_SECRET',
'redirectUri' => 'YOUR_WEB_APPLICATION_REDIRECT_URI',
'javascriptOrigins' => 'YOUR_WEB_APPLICATION_JAVASCRIPT_ORIGINS',
),
*/
'simpleApiKey' => 'AIzaSyAx63Ht-0XmuLdp0-j9zVREKNsCyqXgeUA',
//Scopes needed to access the API data defined by authentication type
'scopes' => array(
'serviceAPI' => array(
'drive' => array(
'https://www.googleapis.com/auth/drive.file',
),
'Analytics'=>array(
'https://www.googleapis.com/auth/analytics.readonly',
),
),
'webappAPI' => array(
'drive' => array(
'https://www.googleapis.com/auth/drive.file',
),
),
),
//Use objects when retriving data from api if true or an array if false
'useObjects'=>false,
);
And how I'm using it:
$api = Yii::app()->JGoogleAPI->getService('Analytics');
$api->data_ga->get(...)
Your access code is invalid. Use refresh token to avoid getting error while authenticating google client.
use the below code:
$gClient->setAccessType("offline");// to get refresh token after expiration of access token
$gClient->setIncludeGrantedScopes(true);