Laravel-Docusign icon indicating copy to clipboard operation
Laravel-Docusign copied to clipboard

Please include the DocuSign's OAuth login flow using JWT Auth because the legacy login flow is getting rejected at the Go-live process.

Open azhar25git opened this issue 3 years ago • 10 comments

DocuSign is removing the legacy login flow and is no longer accepting our app for Live unless we implement OAuth login flow. It would be great if you could update the package to use OAuth.

azhar25git avatar Jan 12 '22 05:01 azhar25git

@azhar25git thanks for the suggestion! As of now, I have limited bandwith for this and wouldn't be able to get to it for a little while.

However, I am definitely open to a PR for this! (would be on the other repo https://github.com/Tucker-Eric/docusign-rest-client).

Tucker-Eric avatar Jan 12 '22 18:01 Tucker-Eric

Users should be aware this will NOT pass "Go-Live" from DocuSign as it does not use OAuth 2.0 . So while this is a great package and I am thankful for the work you have done, it cant be used on a live account. Happy to pay for this to be updated.

JKeaner avatar Jan 14 '22 16:01 JKeaner

Hey @JKeaner

I received your email and am looking into this and appreciate your willingness to pay for this feature. If this is something that can be easily done, there is no need for payment and I'd have no problem doing it. If the scope of this is not small, I would be very open to accepting a PR from anyone you'd want to hire to do this? Or even dropping a bounty on it via https://issuehunt.io or https://www.bountysource.com or another similar service, although I have never used an issue bounty service.

Full disclaimer, I haven't worked with DocuSign myself in a few years so I need to brush up on the changes. I'm curious about the complexity to change and/or if there is a way to implement it now by extending any of the resources of this package.

I am still open to a PR on this and am available to answer questions about the original package for anyone attempting a pr for this.

Tucker-Eric avatar Jan 14 '22 16:01 Tucker-Eric

Thanks for the response @Tucker-Eric . I will see what options I can find to get this updated. If I had any time at all I would try to fix it myself.

Looking at https://developers.docusign.com/platform/auth/

"it doesn't seem that complex." - Every developers famous last words :)

JKeaner avatar Jan 14 '22 16:01 JKeaner

Here is the code I am using. Hope this helps

// DocuSignService class that I created in my project
/*
     * Create the ApiClient using JWT
     */
    public static function createApiClient()
    {
        $config = (new Configuration())->setHost(config('docusign.host'));
        $oAuth = (new OAuth())->setOAuthBasePath(config('docusign.oauth_base_path'));

        $apiClient = new ApiClient($config, $oAuth);
        $apiClient->requestJWTUserToken(
            config('docusign.integrator_key'),
            config('docusign.user_id'),
            config('docusign.private_key'),
            'signature impersonation'
        );

        return $apiClient;
    }

and you can call it like this

$apiClient = DocuSignService::createApiClient();

$envelopesApi = new EnvelopesApi($apiClient);
$envelopeSummary = $envelopesApi->createEnvelope(config('docusign.account_id'), $this->envelopeDefinition);

AdamEsterle avatar Feb 14 '22 19:02 AdamEsterle

@AdamEsterle are you using the DocuSIgn Php SDK?

excalibur1028 avatar Feb 25 '22 21:02 excalibur1028

@excalibur1028 I'm using Tucker-Eric/Laravel-Docusign which uses Tucker-Eric/docusign-rest-client which uses docusign/docusign-esign-php-client

AdamEsterle avatar Feb 26 '22 05:02 AdamEsterle

@AdamEsterle what did you do when the token is first used?

I ended up with something like this.

<?php
namespace App\DocuSign;

use DocuSign\eSign\Client\ApiClient;
use DocuSign\eSign\Client\Auth\OAuth;
use DocuSign\eSign\Configuration;
use Throwable;

/**
 * Helper class to generate a DocuSign Client instance using JWT OAuth2.
 *
 * @see
 *
 */
class OAuthClient
{
    /**
     * Create a new DocuSign API Client instance.
     */
    public static function createApiClient()
    {
        $config = (new Configuration())->setHost(config('docusign.host'));
        $oAuth = (new OAuth())->setOAuthBasePath(config('docusign.oauth_base_path'));

        $apiClient = new ApiClient($config, $oAuth);

        try {
            $response = $apiClient->requestJWTUserToken(
                config('docusign.integrator_key'),
                config('docusign.user_id'),
                config('docusign.private_key'),
                'signature impersonation',
                60
            );

            if ($response) {
                $accessToken = $response[0]['access_token'];

                $accuntInfo = $apiClient->getUserInfo($accessToken);
                $accountId = $accuntInfo[0]['accounts'][0]['account_id'];

                $config->addDefaultHeader('Authorization', 'Bearer ' . $accessToken);

                $apiClient = new ApiClient($config);

                return $apiClient->envelopes->getFormData('1234');
            }
        } catch (Throwable $th) {
            $authorizationUrl = config('docusign.oauth_base_path') . '/oauth/auth?' . http_build_query([
                'scope' => 'signature impersonation',
                'redirect_uri' => config('docusign.redirect_url'),
                'client_id' => config('docusign.integrator_key'),
                'response_type' => 'code'
            ]);

            dd($authorizationUrl);
        }

        return $apiClient;
    }
}

blorange2 avatar Apr 29 '22 14:04 blorange2

@blorange2 I never used the token directly. Just created the apiClient and used that as in my comment above

AdamEsterle avatar Apr 30 '22 17:04 AdamEsterle

Is there something new for implementing the OAuth 2 authentication for Docusign ? I use Symfony framework but I think this feature shoulb be implemented in this repo : https://github.com/Tucker-Eric/docusign-rest-client

Thanks

wehostadm avatar Nov 09 '23 12:11 wehostadm