public static string GetToKen(string session) { ApiContext context = AppSettingHelper.GetGenericApiContext("US"); FetchTokenCall call = new FetchTokenCall(context); return(call.FetchToken(session)); }
public static EbayAuthenticatedCredentials CompleteEbayAuthentication(string sessionId) { // Get token from Ebay var client = EbayClientHelper.GetSdkClient(); // Otherwise get the user id of the logged in user from Ebay log.Debug("Fetching username for Session ID " + sessionId); var userCall = new CallHandlers.ConfirmIdentityCall(client); var ebayUsername = userCall.GetUsername(sessionId).ToLower(); // Always use the lowercase version of the username // Fetch token log.Debug("Fetching token for Session ID " + sessionId); var call = new FetchTokenCall(client); var token = call.FetchToken(sessionId); // If the token comes back empty, that means they didn't complete the sign-in process. if (string.IsNullOrWhiteSpace(token)) { return(null); } else { var data = new EbayAuthenticatedCredentials { SessionId = sessionId, EbayUsername = ebayUsername, Token = token }; log.Debug($"User authenticated: {data}"); return(data); } }
public string GetToken(string sessionid) { var ftc = new FetchTokenCall(api); api.ApiCredential.eBayToken = ftc.FetchToken(sessionid); TokenExpires = ftc.HardExpirationTime; return(api.ApiCredential.eBayToken); }
public static string GetTokenFromeBay(ApiContext apiContext, string SessionId) { FetchTokenCall tokenCall = new FetchTokenCall(apiContext); tokenCall.SessionID = SessionId; tokenCall.Execute(); return(tokenCall.eBayToken); }
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); }
public EbayServiceResponse <string> GetToken(string sessionId) { var apiContext = CreateApiContext(apiServerUrl, ruName, appId, devId, certId); var result = new EbayServiceResponse <string>(); try { var call = new FetchTokenCall(apiContext); result.Result = call.FetchToken(sessionId); } catch (Exception ex) { result.Error = ex.Message; } return(result); }
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); }
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); } }
/// <summary> /// Fetches the token. /// </summary> /// <param name="sessionId">The session identifier.</param> /// <returns></returns> public Task <string> FetchToken(string sessionId) { FetchTokenCall fetchToken = new FetchTokenCall(GetContext()); return(Task.Run(() => fetchToken.FetchToken(sessionId))); }