public void JwtLoginTest()
        {
            testConfig.ApiClient = new ApiClient(testConfig.Host);
            testConfig.ApiClient.ConfigureJwtAuthorizationFlow(testConfig.IntegratorKey, testConfig.UserId, testConfig.OAuthBasePath, testConfig.PrivateKeyFilename, testConfig.ExpiresInHours);

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            AuthenticationApi authApi   = new AuthenticationApi(testConfig.ApiClient.Configuration);
            LoginInformation  loginInfo = authApi.Login();

            Assert.IsNotNull(loginInfo);
            Assert.IsNotNull(loginInfo.LoginAccounts);

            // find the default account for this user
            foreach (LoginAccount loginAcct in loginInfo.LoginAccounts)
            {
                if (loginAcct.IsDefault == "true" || testConfig.AccountId == null)
                {
                    testConfig.AccountId = loginAcct.AccountId;

                    string[] separatingStrings = { "/v2" };

                    // Update ApiClient with the new base url from login call
                    testConfig.ApiClient = new ApiClient(loginAcct.BaseUrl.Split(separatingStrings, StringSplitOptions.RemoveEmptyEntries)[0]);
                    //testConfig.Configuration = config;
                    break;
                }
            }
            Assert.IsNotNull(testConfig.AccountId);
        }
示例#2
0
        public string GetAccountID()
        {
            #region auth_details
            string integratorKey = ConfigurationManager.AppSettings["IntegratorKey"];
            string email         = ConfigurationManager.AppSettings["DocuSignUserEmail"];
            string password      = ConfigurationManager.AppSettings["DocuSignPassword"];

            string authHeader = "{\"Username\":\"" + email + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";
            #endregion

            DocuSign.eSign.Client.Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            #region attemptlogin
            ApiClient client = new ApiClient(basePath: "https://demo.docusign.net/restapi");
            DocuSign.eSign.Client.Configuration configHeader = new DocuSign.eSign.Client.Configuration(client);
            configHeader.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
            AuthenticationApi authApi = new AuthenticationApi(configHeader);


            LoginInformation loginInfo = authApi.Login();

            #endregion

            return(loginInfo.LoginAccounts[0].AccountId);
        }
示例#3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            services.AddSingleton(async mantleConfig =>
            {
                var config = new Configuration
                {
                    BasePath = "https://api.mantle.services"
                };
                var auth         = new AuthenticationApi(config);
                var userResponse = await auth.AuthenticationLoginPostAsync(new UserLoginRequest("mantleEmail", "mantlePass"));
                config.AddDefaultHeader("Authorization", userResponse.AccessToken);
                return(config);
            });

            var corsBuilder = new CorsPolicyBuilder();

            corsBuilder.AllowAnyHeader();
            corsBuilder.AllowAnyMethod();
            corsBuilder.AllowAnyOrigin();
            corsBuilder.AllowCredentials();

            services.AddCors(options =>
            {
                options.AddPolicy("SiteCorsPolicy", corsBuilder.Build());
            });
        }
示例#4
0
        public static string GetAccountId()
        {
            var    appSettings   = System.Configuration.ConfigurationManager.AppSettings;
            string username      = appSettings["docusignDeveloperEmail"] ?? "*****@*****.**";
            string password      = appSettings["docusignPassword"] ?? "epercic";
            string integratorKey = appSettings["docusignIntegratorKey"] ?? "a2dced5d-bebe-4b70-803e-bbbb70ecf7cb";

            string authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";

            Configuration.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            AuthenticationApi authApi   = new AuthenticationApi(Configuration);
            LoginInformation  loginInfo = authApi.Login();

            // find the default account for this user
            foreach (LoginAccount loginAccount in loginInfo.LoginAccounts)
            {
                if (loginAccount.IsDefault == "true")
                {
                    return(loginAccount.AccountId);
                }
            }

            return(null);
        }
示例#5
0
        /// <summary>
        /// Login this instance.
        /// </summary>
        public static void Login()
        {
            var username      = Settings.Default.Username;
            var password      = Settings.Default.Password;
            var integratorKey = Settings.Default.IntegratorKey;
            var restUrl       = Settings.Default.RestUrl;

            // initialize client for desired environment (for production change to www)
            var apiClient = new ApiClient(restUrl);

            Configuration.Default.ApiClient = apiClient;

            // configure 'X-DocuSign-Authentication' header
            var authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password +
                             "\", \"IntegratorKey\":\"" + integratorKey + "\"}";

            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            // we will retrieve this from the login API call
            string accountId = null;

            /////////////////////////////////////////////////////////////////
            // STEP 1: LOGIN API
            /////////////////////////////////////////////////////////////////

            // login call is available in the authentication api
            var authApi   = new AuthenticationApi();
            var loginInfo = authApi.Login();

            // parse the first account ID that is returned (user might belong to multiple accounts)
            accountId = loginInfo.LoginAccounts[0].AccountId;

            AccountId = accountId;
        }
        public void LegacyLoginTest()
        {
            string authHeader = "{\"Username\":\"" + testConfig.Username + "\", \"Password\":\"" + testConfig.Password + "\", \"IntegratorKey\":\"" + testConfig.IntegratorKey + "\"}";

            testConfig.ApiClient = new ApiClient(testConfig.Host);
            if (testConfig.ApiClient.Configuration.DefaultHeader.ContainsKey("X-DocuSign-Authentication"))
            {
                testConfig.ApiClient.Configuration.DefaultHeader.Remove("X-DocuSign-Authentication");
            }
            testConfig.ApiClient.Configuration.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object

            AuthenticationApi authApi   = new AuthenticationApi(testConfig.ApiClient.Configuration);
            LoginInformation  loginInfo = authApi.Login();

            Assert.IsNotNull(loginInfo);
            Assert.IsNotNull(loginInfo.LoginAccounts);

            // find the default account for this user
            foreach (LoginAccount loginAcct in loginInfo.LoginAccounts)
            {
                if (loginAcct.IsDefault == "true" || testConfig.AccountId == null)
                {
                    testConfig.AccountId = loginAcct.AccountId;

                    string[] separatingStrings = { "/v2" };

                    // Update ApiClient with the new base url from login call
                    testConfig.ApiClient = new ApiClient(loginAcct.BaseUrl.Split(separatingStrings, StringSplitOptions.RemoveEmptyEntries)[0]);
                    break;
                }
            }
            Assert.IsNotNull(testConfig.AccountId);
        }
示例#7
0
        public void LoginTest()
        {
            // configure the ApiClient for the DocuSign site and authentictaion needed.
            Utils.ConfigureApiClient();


            AuthenticationApi authApi = new AuthenticationApi();

            AuthenticationApi.LoginOptions options = new AuthenticationApi.LoginOptions();
            options.apiPassword          = "******";
            options.includeAccountIdGuid = "true";
            LoginInformation loginInfo = authApi.Login(options);

            Assert.IsNotNull(loginInfo.LoginAccounts);

            // find the default account for this user
            foreach (LoginAccount loginAcct in loginInfo.LoginAccounts)
            {
                if (loginAcct.IsDefault == "true")
                {
                    TestConfig.AccountId = loginAcct.AccountId;
                    break;
                }
            }
            Assert.IsNotNull(TestConfig.AccountId);
        }
示例#8
0
        public static string GetAccountId()
        {
            var    appSettings   = System.Configuration.ConfigurationManager.AppSettings;
            string username      = appSettings["docusignDeveloperEmail"] ?? "*****@*****.**";
            string password      = appSettings["docusignPassword"] ?? "N#ewport4331";
            string integratorKey = appSettings["docusignIntegratorKey"] ?? "4ed5be53-a1e4-49d4-80bd-563d4635eb9d";

            string authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";

            Configuration.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            AuthenticationApi authApi   = new AuthenticationApi(Configuration);
            LoginInformation  loginInfo = authApi.Login();

            // find the default account for this user
            foreach (LoginAccount loginAccount in loginInfo.LoginAccounts)
            {
                if (loginAccount.IsDefault == "true")
                {
                    return(loginAccount.AccountId);
                }
            }

            return(null);
        }
示例#9
0
        public static string GetAccountId()
        {
            var    appSettings   = System.Configuration.ConfigurationManager.AppSettings;
            string username      = appSettings["docusignDeveloperEmail"] ?? "*****@*****.**";
            string password      = appSettings["docusignPassword"] ?? "gopala";
            string integratorKey = appSettings["docusignIntegratorKey"] ?? "TEST-5913deaf-c9d9-4d6b-a8a0-2d7ca76db2f5";

            string authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";

            Configuration.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            AuthenticationApi authApi   = new AuthenticationApi(Configuration);
            LoginInformation  loginInfo = authApi.Login();

            // find the default account for this user
            foreach (LoginAccount loginAccount in loginInfo.LoginAccounts)
            {
                if (loginAccount.IsDefault == "true")
                {
                    return(loginAccount.AccountId);
                }
            }

            return(null);
        }
示例#10
0
        public void MyTestCleanup()
        {
            AuthenticationApi authenticationApi = new AuthenticationApi(this.DsmApiContext);

            authenticationApi.LogOff().Wait();
            this.DsmApiContext = null;
        }
示例#11
0
        public static string loginApi(string user, string password)
        {
            ApiClient apiClient     = Configuration.Default.ApiClient;
            string    integratorKey = System.Configuration.ConfigurationManager.AppSettings["INTEGRATOR_KEY"];
            string    authHeader    = $"{{\"Username\":\"{user}\",\"Password\":\"{password}\",\"IntegratorKey\":\"{integratorKey}\"}}";

            Configuration.Default.AddDefaultHeader(DocuSignConstants.DocuSignHeader, authHeader);

            string accountId = null;

            AuthenticationApi authApi   = new AuthenticationApi();
            LoginInformation  loginInfo = authApi.Login();

            foreach (LoginAccount loginAcct in loginInfo.LoginAccounts)
            {
                if (loginAcct.IsDefault == "true")
                {
                    accountId = loginAcct.AccountId;
                    break;
                }
            }

            if (accountId == null && loginInfo.LoginAccounts.Count > 0)
            {
                accountId = loginInfo.LoginAccounts[0].AccountId;
            }

            return(accountId);
        }
示例#12
0
        public string loginApi(string usr, string pwd)
        {
            usr = "******";
            pwd = "Cns@12345";
            // we set the api client in global config when we configured the client
            ApiClient apiClient  = Configuration.Default.ApiClient;
            string    authHeader = "{\"Username\":\"" + usr + "\", \"Password\":\"" + pwd + "\", \"IntegratorKey\":\"" + INTEGRATOR_KEY + "\"}";

            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
            // we will retrieve this from the login() results
            string accountId = null;
            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            AuthenticationApi authApi   = new AuthenticationApi();
            LoginInformation  loginInfo = authApi.Login();

            // find the default account for this user
            foreach (DocuSign.eSign.Model.LoginAccount loginAcct in loginInfo.LoginAccounts)
            {
                if (loginAcct.IsDefault == "true")
                {
                    accountId = loginAcct.AccountId;
                    break;
                }
            }
            if (accountId == null)
            { // if no default found set to first account
                accountId = loginInfo.LoginAccounts[0].AccountId;
            }
            return(accountId);
        }
示例#13
0
        public void OAuthAuthorizationCodeFlowTest()
        {
            // Make an API call with the token
            ApiClient apiClient = new ApiClient(BaseUrl);

            DocuSign.eSign.Client.Configuration.Default.ApiClient = apiClient;

            // Initiate the browser session to the Authentication server
            // so the user can login.
            string accountServerAuthUrl = apiClient.GetAuthorizationUri(client_id, redirect_url, true, stateOptional);

            System.Diagnostics.Process.Start(accountServerAuthUrl);

            WaitForCallbackEvent = new ManualResetEvent(false);

            // Launch a self-hosted web server to accepte the redirect_url call
            // after the user finishes authentication.
            using (WebApp.Start <Startup>("http://localhost:3000"))
            {
                Trace.WriteLine("WebServer Running. Waiting for access_token...");

                // This waits for the redirect_url to be received in the REST controller
                // (see classes below) and then sleeps a short time to allow the response
                // to be returned to the web browser before the server session ends.
                WaitForCallbackEvent.WaitOne(60000, false);
                Thread.Sleep(1000);
            }
            Assert.IsNotNull(AccessCode);

            string accessToken = apiClient.GetOAuthToken(client_id, client_secret, true, AccessCode);

            Assert.IsNotNull(accessToken);
            Trace.WriteLine("Access_token: " + accessToken);

            // we will retrieve this from the login API call
            string accountId = null;

            /////////////////////////////////////////////////////////////////
            // STEP 1: LOGIN API
            /////////////////////////////////////////////////////////////////

            // login call is available in the authentication api
            AuthenticationApi authApi   = new AuthenticationApi();
            LoginInformation  loginInfo = authApi.Login();

            // parse the first account ID that is returned (user might belong to multiple accounts)
            accountId = loginInfo.LoginAccounts[0].AccountId;

            // Update ApiClient with the new base url from login call
            apiClient = new ApiClient(loginInfo.LoginAccounts[0].BaseUrl);

            /////////////////////////////////////////////////////////////////
            // STEP 2: CREATE ACCOUNTS API
            /////////////////////////////////////////////////////////////////
            AccountsApi        accountsApi        = new AccountsApi();
            AccountInformation accountInformation = accountsApi.GetAccountInformation(accountId);

            Trace.WriteLine(accountInformation.ToString());
        }
示例#14
0
        public IActionResult GetToken([FromBody] LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var token = new AuthenticationApi().GetToken(model);

                return(Ok(token));
            }
            return(BadRequest());
        }
示例#15
0
        public async Task Auth(string email, string password)
        {
            Configuration = new Configuration(new ApiClient(URL));

            var auth = new AuthenticationApi(Configuration);

            var tokenres = await auth.AuthenticationLoginPostAsync(new LoginDto(email, password));

            SetToken(tokenres?.Token);
        }
        public IActionResult LRForgotPassword([FromBody] ForgotPasswordModel forgotPassModel, [FromQuery(Name = "reset_password_url")] String resetPasswordUrl)
        {
            var apiresponse = new AuthenticationApi().ForgotPassword(forgotPassModel.Email, resetPasswordUrl, "");

            if (apiresponse.RestException != null)
            {
                return(StatusCode(400, Json(apiresponse.RestException)));
            }
            return(Json(apiresponse.Response));
        }
示例#17
0
        public IActionResult LRGetProfile([FromQuery(Name = "auth")] String accessToken)
        {
            var apiresponse = new AuthenticationApi().GetProfileByAccessToken(accessToken);

            if (apiresponse.RestException != null)
            {
                return(StatusCode(400, Json(apiresponse.RestException)));
            }
            return(Json(apiresponse.Response));
        }
示例#18
0
        public virtual void MyTestInitialize()
        {
            this.DsmApiContext = ServiceLocator.Current.GetInstance <IDsmApiContext>();
            this.DsmApiContext.LoadAllApiInfo().Wait();
            AuthenticationApi authenticationApi = new AuthenticationApi(this.DsmApiContext);
            string            account           = ConfigurationManager.AppSettings["dsm_account"];
            string            password          = ConfigurationManager.AppSettings["dsm_password"];

            authenticationApi.LogOn(account, password).Wait();
        }
        public AuthManager(Uri baseUri)
        {
            this.credService = new EncryptedCredentialsService();
            this.authApi     = new AuthenticationApi(baseUri);
            Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            ClientKey         = configuration.AppSettings.Settings["ClientKey"].Value;
            PublicKey         = configuration.AppSettings.Settings["PublicKey"].Value;
            EncryptedPassword = configuration.AppSettings.Settings["EncryptedPassword"].Value;
        }
示例#20
0
        public IActionResult LRChangePassword([FromBody] ChangePasswordModel changePasswordModel, [FromQuery(Name = "auth")] String accessToken)
        {
            var apiresponse = new AuthenticationApi().ChangePassword(accessToken, changePasswordModel.newPassword, changePasswordModel.oldPassword);

            if (apiresponse.RestException != null)
            {
                return(StatusCode(400, Json(apiresponse.RestException)));
            }
            return(Json(apiresponse.Response));
        }
        public IActionResult LRVerifyEmail([FromQuery(Name = "verification_token")] String verificationToken)
        {
            var apiresponse = new AuthenticationApi().VerifyEmail(verificationToken, "google.ca", "");

            if (apiresponse.RestException != null)
            {
                return(StatusCode(400, Json(apiresponse.RestException)));
            }
            return(Json(apiresponse.Response));
        }
示例#22
0
        static AccessTokenResponse GetAccessToken(string basePath, string username, string password)
        {
            var apiInstance = new AuthenticationApi(basePath);
            var body        = new AccessTokenRequest(Name: username, Password: password, AppId: "Tradovate.MarketData.SampleApp", AppVersion: "0.1.0");

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            AccessTokenResponse result = apiInstance.AccessTokenRequest(body);

            Debug.WriteLine(result);
            return(result);
        }
示例#23
0
        public async Task Auth(string email, string password, string server)
        {
            Console.WriteLine("Dowding Auth");
            Configuration = new Configuration(new ApiClient(String.Format(URL, server)));

            var auth = new AuthenticationApi(Configuration);

            var tokenres = await auth.AuthenticationLoginPostAsync(new LoginDto(email, password));

            SetToken(tokenres?.Token, server);
        }
示例#24
0
        public string SendOauthRequest()

        {
            string token = "";

            AuthenticationApi authApi = new AuthenticationApi("https://account-d.docusign.com");
            OauthAccess       oAuth   = authApi.GetOAuthToken();

            token = oAuth.AccessToken;

            return(token);
        }
示例#25
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Configuration.Default.BasePath = "https://test.deribit.com/api/v2";
            // Configure HTTP basic authorization: bearerAuth
            Configuration.Default.Username = "******";
            Configuration.Default.Password = "******";

            //Configuration.Default.AccessToken = "gjF0ypJxao-8hmycbfgemBCjTtRnR9MMLxFxSkVoMyA";

            authApiInstance    = new AuthenticationApi(Configuration.Default);
            privateApiInstance = new PrivateApi(Configuration.Default);
        }
示例#26
0
        private void ConfigureApiClientAuth_OldMethod(ApiClient apiClient)
        {
            var username      = this.Configuration["Docusign:username"];
            var password      = this.Configuration["Docusign:password"];
            var integratorKey = this.Configuration["Docusign:clientId"];
            var authHeader    = $"{{\"Username\":\"{username}\", \"Password\":\"{password}\", \"IntegratorKey\":\"{integratorKey}\"}}";

            apiClient.Configuration.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            var authApi = new AuthenticationApi();

            authApi.Login();
        }
示例#27
0
        static void Main(string[] args)
        {
            string[] userName     = new string[5];
            string[] userPassword = new string[5];
            string[] consumerKey  = new string[5];
            int      i;


            userName[0]     = "*****@*****.**";
            userPassword[0] = "apprenticeship123";
            consumerKey[0]  = "	deUbbIVOpyiHCpA10ogMAI5VWMJ7GDNb";

            userName[1]     = "*****@*****.**";
            userPassword[1] = "chocolatemuffin01";
            consumerKey[1]  = "	deUbbIVOpyiHCpA10ogMAI5VWMJ7GDNb";

            userName[2]     = "*****@*****.**";
            userPassword[2] = "blueberrymuffin02";
            consumerKey[2]  = "	deUbbIVOpyiHCpA10ogMAI5VWMJ7GDNb";

            userName[3]     = "*****@*****.**";
            userPassword[3] = "Chocolate18";
            consumerKey[3]  = "	deUbbIVOpyiHCpA10ogMAI5VWMJ7GDNb";

            userName[4]     = "*****@*****.**";
            userPassword[4] = "password123";
            consumerKey[4]  = "	deUbbIVOpyiHCpA10ogMAI5VWMJ7GDNb";

            var authApi = new AuthenticationApi();

            for (i = 0; i < 5; i++)
            {
                try
                {
                    var response    = authApi.directLogin(userName[i], userPassword[i], consumerKey[i], "password");
                    var accessToken = response.access_token;

                    var meetingsApi = new MeetingsApi();
                    var meetings    = meetingsApi.getUpcomingMeetings(accessToken);

                    foreach (var m in meetings)
                    {
                        Console.WriteLine("{0}|{1}|{2}|{3}", userName[i], m.meetingId, m.startTime, m.subject);
                    }
                }
                catch
                {
                    // Stop error on screen
                }
            }
        }
示例#28
0
 public Gateway(ClientContext _context)
 {
     context         = _context;
     authApi         = new AuthenticationApi(context.Config);
     orderApi        = new OrderApi(context.Config);
     payApi          = new PaymentApi(context.Config);
     verifyApi       = new VerificationApi(context.Config);
     currencyApi     = new CurrencyConversionApi(context.Config);
     fraudApi        = new FraudDetectApi(context.Config);
     paySchedulesApi = new PaymentSchedulesApi(context.Config);
     payTokenApi     = new PaymentTokenApi(context.Config);
     payUrlApi       = new PaymentURLApi(context.Config);
     infoApi         = new InformationLookupApi(context.Config);
 }
        public IActionResult LRResetPasswordEmail([FromBody] ResetPasswordModel resetPasswordModel)
        {
            ResetPasswordByResetTokenModel reset = new ResetPasswordByResetTokenModel
            {
                Password   = resetPasswordModel.password,
                ResetToken = resetPasswordModel.resettoken
            };
            var apiresponse = new AuthenticationApi().ResetPasswordByResetToken(reset);

            if (apiresponse.RestException != null)
            {
                return(StatusCode(400, Json(apiresponse.RestException)));
            }
            return(Json(apiresponse.Response));
        }
示例#30
0
        public void Connect()
        {
            _client = new HttpPilotClient(_settings.ServerUrl);
            _client.Connect(false);

            ServerApi         = _client.GetServerApi(new NullableServerCallback());
            AuthenticationApi = _client.GetAuthenticationApi();
            AuthenticationApi.Login(_settings.DbName, _settings.Login, _settings.Password, false, _settings.LicenseCode);

            var dataBaseInfo = ServerApi.OpenDatabase();

            PersonId = dataBaseInfo.Person.Id;

            FileArchiveApi = _client.GetFileArchiveApi();
        }
 public void TestConstructorArgumentNullException()
 {
     var authenticationApi = new AuthenticationApi(null);
 }
 public override void MyTestInitialize()
 {
     base.MyTestInitialize();
     this.AuthenticationApi = new AuthenticationApi(this.DsmApiContext);
 }