Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Adobe Sign access token for server-to-server authentication

Tags:

adobe

echosign

I'm currently trying to build a back-end system, i.e. no user interface which should send documents out for signature using Echosign.

The page for configuring the Oath token requires a redirect URL, but obviously my application doesn't have a UI and therefore no redirect URL either.

Clearly there is a whole OAuth world that I can dive into now, but I'm hoping to use their API quickly without needing to understand all the ins-and-outs of OAuth first. All of the samples seem to be based on a web interface scenario, which is not the case for me.

Any pointers would be appreciated.

like image 286
Greg Fullard Avatar asked Jan 06 '17 12:01

Greg Fullard


People also ask

How do I get an access token from an authorization server?

After you add the authorization profile, you need to get access token from the server. In this tutorial, we get it by using the Authorization Code grant method: Click Get Token. In the subsequent dialog, enter Client Identification and Secret, Authorization URI, Access Token URI and Redirect URI.

How can I get access token using authorization code?

To get a new access token, use the refresh token as you would an authorization code, but with a grant_type value of refresh_token and a refresh_token parameter that holds the contents of the refresh token. The type of grant being used. To exchange a refresh token for an access token, use refresh_token .


3 Answers

The only way I've been able to do things like this in the past is to initially follow the default authentication process, then once you have an access token you can create a cron task that runs every say 30 minutes to refresh your access token before it expires.

As long as the cron task continues to run you will always have a valid access token and wont need to go through the login/redirect url process.

like image 59
bananabread_ Avatar answered Sep 29 '22 18:09

bananabread_


I would contact Adobe support. They can enable an integration key within your Adobe Sign account that would allow you to integrate with a static key that you could use integrate with your backend system instead of OAUTH.

like image 40
Ben Vanderberg Avatar answered Sep 29 '22 19:09

Ben Vanderberg


_bananabread has the right idea. Follow the steps on this website:

https://www.adobe.io/apis/documentcloud/sign/docs/step-by-step-guide/get-the-access-token.html

up until you have your JSON response with your refresh_token, this is all you need.

Next, you going to need to make a refresh token request that refreshes your token everytime you need to use it and returns you a brand new OAuth token.

Here is a Java code snippet that will refresh your acquired token:

    HttpResponse response = null;
    String access_token = "";
    HttpClient httpClient = HttpClientBuilder.create().build();
    HttpPost request = new HttpPost("http://api.echosign.com/oauth/refresh?"+
                                        "refresh_token=tokenYouJustGot&" +
                                        "client_id=clientIdUsedInPreviousSteps&"+
                                        "client_secret=clientSecretUsedInPreviousStep"+
                                        "grant_type=refresh_token");


    request.addHeader("content-type", "application/x-www-form-urlencoded");
    response = httpClient.execute(request);
    String json = EntityUtils.toString(response.getEntity());
    JSONObject jobj = new JSONObject(json);
    access_token = jobj.getString("access_token");

access_token String will now contain a brand new OAuth access token with you can use for any request ie POST or GET.

like image 20
RetroPanda Avatar answered Sep 29 '22 18:09

RetroPanda