protected override IAsyncResult BeginExecute(NativeActivityContext context, AsyncCallback callback, object state)
        {
            string restApiUrl = RestApiUrl.Get(context);

            if (!restApiUrl.EndsWith("/"))
            {
                restApiUrl += "/";
            }
            string client_id = ClientId.Get(context);
            string client_secret;

            if (ClientSecretSecure.Get(context) != null)
            {
                client_secret = SecureStringToString(ClientSecretSecure.Get(context));
            }
            else
            {
                client_secret = ClientSecretInsecure.Get(context);
            }

            string redirect_uri  = RedirectUrl.Get(context);
            int    serverTimeout = TimeoutMS.Get(context);


            authAgent = new AuthenticationAgent(restApiUrl, client_id, client_secret, redirect_uri, serverTimeout);

            authAgent.GetAuthUrl();

            ScheduleAuthActivities(context);

            AuthenticateAsyncDelegate = new Action(AuthenticateAsync);
            return(AuthenticateAsyncDelegate.BeginInvoke(callback, state));
        }
        protected void LoadAuthentication(AsyncCodeActivityContext context)
        {
            var property = context.DataContext.GetProperties()["authAgent"];

            if (property.GetValue(context.DataContext) == null)
            {
                throw new Exception("DocuSign activities must be within DocuSign Context activity");
            }
            authAgent = (AuthenticationAgent)property.GetValue(context.DataContext);
        }
        protected override void Execute(NativeActivityContext context)
        {
            var property = context.DataContext.GetProperties()["authAgent"];

            if (property.GetValue(context.DataContext) == null)
            {
                throw new Exception("DocuSign activities must be within DocuSign Context activity");
            }
            AuthenticationAgent authAgent = (AuthenticationAgent)property.GetValue(context.DataContext);

            AuthenticationUrl.Set(context, authAgent.authUrl);
        }
Example #4
0
 protected void BuildDefaultAuthUrl(AsyncCodeActivityContext context)
 {
     if (authUrl == null)
     {
         var property = context.DataContext.GetProperties()["authAgent"];
         if (property.GetValue(context.DataContext) == null)
         {
             throw new Exception("DocuSign activities must be within DocuSign Context activity");
         }
         AuthenticationAgent authAgent = (AuthenticationAgent)property.GetValue(context.DataContext);
         authUrl = authAgent.authUrl;
     }
 }
        protected override IAsyncResult BeginExecute(NativeActivityContext context, AsyncCallback callback, object state)
        {
            string restApiUrl = RestApiUrl.Get(context);

            if (!restApiUrl.EndsWith("/"))
            {
                restApiUrl += "/";
            }
            string client_id = ClientId.Get(context);
            string client_secret;

            if (ClientSecretSecure.Get(context) != null)
            {
                client_secret = SecureStringToString(ClientSecretSecure.Get(context));
            }
            else
            {
                client_secret = ClientSecretInsecure.Get(context);
            }

            string redirect_uri  = RedirectUrl.Get(context);
            int    serverTimeout = TimeoutMS.Get(context);


            authAgent = new AuthenticationAgent(restApiUrl, client_id, client_secret, redirect_uri, serverTimeout);

            if (AuthentificationTokenIn.Get(context) != null)
            {
                authAgent.authToken = JsonConvert.DeserializeObject <AuthToken>(AuthentificationTokenIn.Get(context));
                authAgent.GetAuthUrl();
                authAgent.authCode        = JsonConvert.DeserializeObject <ConcurrentDictionary <string, string> >(AuthentificationCodeIn.Get(context));
                AuthenticateAsyncDelegate = new Action(ConfigureAuthentification);
            }
            else
            {
                authAgent.GetAuthUrl();
                ScheduleAuthActivities(context);
                AuthenticateAsyncDelegate = new Action(AuthenticateAsync);
            }

            return(AuthenticateAsyncDelegate.BeginInvoke(callback, state));
        }