public static String getAuthenticateUrl(out String sessionId) { sessionId = ""; 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); GetSessionIDCall apiCall = new GetSessionIDCall(localContext); apiCall.RuName = EbayRuName; apiCall.Execute(); sessionId = apiCall.SessionID; String authUrl = String.Format("{0}&RuName={1}&SessID={2}", localContext.SignInUrl, EbayRuName, sessionId); return(authUrl); }
// Test API // https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx public static string CreateSessionID(ApiContext apiContext) { GetSessionIDCall sessionId = new GetSessionIDCall(apiContext); sessionId.RuName = ConfigurationManager.AppSettings["RuName"]; sessionId.ApiContext.ApiCredential.ApiAccount.Application = ConfigurationManager.AppSettings["AppID"]; sessionId.ApiContext.ApiCredential.ApiAccount.Developer = ConfigurationManager.AppSettings["DevID"]; sessionId.ApiContext.ApiCredential.ApiAccount.Certificate = ConfigurationManager.AppSettings["CertID"]; sessionId.Execute(); apiContext.ApiLogManager.RecordMessage(String.Format("*** Session ID: {0}", sessionId.SessionID)); string uri = String.Format("https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn&RuName={0}&SessID={1}", ConfigurationManager.AppSettings["RuName"], sessionId.SessionID); apiContext.ApiLogManager.RecordMessage(String.Format("*** URL: {0}", uri)); uri = String.Format("https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn&RuName={0}&SessID={1}", ConfigurationManager.AppSettings["RuName"], HttpUtility.UrlEncode(sessionId.SessionID)); apiContext.ApiLogManager.RecordMessage(String.Format("*** URL encoded: {0}", uri)); return(sessionId.SessionID); }