Esempio n. 1
0
 public void FetchToken()
 {
     FetchTokenCall api = new FetchTokenCall(this.apiContext);
     api.SessionID = "NoSuchOne";
     ApiException gotException = null;
     try
     {
         api.Execute();
         String token = api.eBayToken;
         Assert.IsNotNull(token);
     }
     catch(ApiException ex)
     {
         gotException = ex;
     }
     Assert.IsNotNull(gotException);
 }
Esempio n. 2
0
        public static String FetchUserToken(String sessionId, out String userId)
        {
            userId = "";

            if (sessionId == "")
                return "";

            String token = "";

            ApiAccount apiAccount = new ApiAccount();
            apiAccount.Application = EbayAppId;
            apiAccount.Certificate = EbayCertId;
            apiAccount.Developer = EbayDevId;

            ApiContext localContext = new ApiContext();
            localContext.ApiCredential = new eBay.Service.Core.Sdk.ApiCredential();
            localContext.ApiCredential.ApiAccount = apiAccount;
            localContext.RuName = EbayRuName;
            localContext.SoapApiServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(AppSettingHelper.API_SERVER_URL);
            localContext.SignInUrl = System.Configuration.ConfigurationManager.AppSettings.Get(AppSettingHelper.SIGNIN_URL);

            ConfirmIdentityCall apiCall = new ConfirmIdentityCall(localContext);
            apiCall.SessionID = sessionId;
            try
            {
                apiCall.ConfirmIdentity(sessionId);
                userId = apiCall.UserID;
            }
            catch (System.Exception)
            {
            }

            FetchTokenCall fetchTokenApiCall = new FetchTokenCall(localContext);
            apiCall.SessionID = sessionId;
            try
            {
                fetchTokenApiCall.FetchToken(sessionId);
                token = fetchTokenApiCall.eBayToken;
            }
            catch (System.Exception)
            {
            }

            return token;
        }
Esempio n. 3
0
 private void BtnFetchToken_Click(object sender, System.EventArgs e)
 {
     try
     {
         if(TxtSessionID.Text.Length == 0)
         {
             MessageBox.Show("Please retrieve a SessionID first, then launch Sign-In, before fetch token!");
             return;
         }
         FetchTokenCall ftc = new FetchTokenCall(Context);
         Context.ApiCredential.eBayToken = ftc.FetchToken(TxtSessionID.Text);
         this.TabSettings.SelectedTab = this.TabPageCredentials;
         TxtToken.Text = Context.ApiCredential.eBayToken;
         TxtToken.Focus();
     }
     catch (ApiException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 public static string GetToKen(string session)
 {
     ApiContext context = AppSettingHelper.GetGenericApiContext("US");
     FetchTokenCall call = new FetchTokenCall(context);
     return call.FetchToken(session);
 }