public void GivenIHaveClientCredentials()
 {
     ScenarioContext.Current.Set(
         ConnectSdk.GetConnectSdkWithClientCredentials(
             Environment.GetEnvironmentVariable("ConnectSDK_ApiKey"),
             Environment.GetEnvironmentVariable("ConnectSDK_ApiSecret")));
 }
 public void GivenIHaveResourceOwnerCredentials()
 {
     ScenarioContext.Current.Set(
         ConnectSdk.GetConnectSdkWithResourceOwnerCredentials(
             Environment.GetEnvironmentVariable("ConnectSDK_ApiKey"),
             Environment.GetEnvironmentVariable("ConnectSDK_ApiSecret"),
             Environment.GetEnvironmentVariable("ConnectSDK_UserName"),
             Environment.GetEnvironmentVariable("ConnectSDK_UserPassword")));
 }
        public void GivenARefreshToken()
        {
            var connect = ConnectSdk.GetConnectSdkWithResourceOwnerCredentials(
                ScenarioContext.Current.Get <string>("apikey"),
                ScenarioContext.Current.Get <string>("apisecret"),
                Environment.GetEnvironmentVariable("ConnectSDK_UserName"),
                Environment.GetEnvironmentVariable("ConnectSDK_UserPassword"));
            var refreshToken = connect.GetAccessToken().Result.RefreshToken;

            ScenarioContext.Current.Add("refreshtoken", refreshToken);
        }
        public static ConnectSdk GetCredentials()
        {
            if (ScenarioContext.Current.ContainsKey("apikey") &&
                ScenarioContext.Current.ContainsKey("apisecret") &&
                ScenarioContext.Current.ContainsKey("refreshtoken"))
            {
                return(ConnectSdk.GetConnectSdkWithRefreshToken(ScenarioContext.Current.Get <string>("apikey"),
                                                                ScenarioContext.Current.Get <string>("apisecret"),
                                                                ScenarioContext.Current.Get <string>("refreshtoken")));
            }

            if (ScenarioContext.Current.ContainsKey("apikey") &&
                ScenarioContext.Current.ContainsKey("apisecret") &&
                !ScenarioContext.Current.ContainsKey("username"))
            {
                return(ConnectSdk.GetConnectSdkWithClientCredentials(
                           ScenarioContext.Current.Get <string>("apikey"),
                           ScenarioContext.Current.Get <string>("apisecret")));
            }

            if (ScenarioContext.Current.ContainsKey("apikey") &&
                ScenarioContext.Current.ContainsKey("apisecret") &&
                ScenarioContext.Current.ContainsKey("username") &&
                ScenarioContext.Current.ContainsKey("userpassword"))
            {
                return(ConnectSdk.GetConnectSdkWithResourceOwnerCredentials(
                           ScenarioContext.Current.Get <string>("apikey"),
                           ScenarioContext.Current.Get <string>("apisecret"),
                           ScenarioContext.Current.Get <string>("username"),
                           ScenarioContext.Current.Get <string>("userpassword")));
            }

            Assert.Fail(
                "Unable to determine which credentials to use. Did you include the proper steps in your scenario?");

            return(null);
        }