Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
azhar25git opened this issue Jan 12, 2022 · 10 comments

Comments

@azhar25git
Copy link

azhar25git commented Jan 12, 2022

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.

@Tucker-Eric
Copy link
Owner

@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).

@JKeaner
Copy link

JKeaner commented Jan 14, 2022

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.

@Tucker-Eric
Copy link
Owner

Tucker-Eric commented Jan 14, 2022

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.

@JKeaner
Copy link

JKeaner commented Jan 14, 2022

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 :)

@AdamEsterle
Copy link
Contributor

AdamEsterle commented Feb 14, 2022

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);

@excalibur1028
Copy link

@AdamEsterle are you using the DocuSIgn Php SDK?

@AdamEsterle
Copy link
Contributor

AdamEsterle commented Feb 26, 2022

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

@blorange2
Copy link

@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;
    }
}

@AdamEsterle
Copy link
Contributor

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

@wehostadm
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants