示例#1
0
        private static AmazonSecurityInfo GetAuthToken(string accessKey, string secretKey, string SellerId)
        {
            // The client application name
            string appName = "C#";

            // The client application version
            string appVersion = "4.0";

            // The endpoint for region service and version (see developer guide)
            string serviceURL = "https://mws.amazonservices.co.uk";

            // Create a configuration object
            MarketplaceWebServiceSellersConfig config = new MarketplaceWebServiceSellersConfig();

            config.ServiceURL = serviceURL;

            // Create the client itself
            var client = new MarketplaceWebServiceSellersClient(appName, appVersion, accessKey, secretKey, config);

            //Create the request object
            GetAuthTokenRequest req = new GetAuthTokenRequest();

            req.SellerId = SellerId;

            try
            {
                //Try connecting to server to aquire requested data
                GetAuthTokenResponse response = client.GetAuthTokenStatus(req);
                //Create resault objext
                AmazonSecurityInfo result = new AmazonSecurityInfo();
                //Fill in the aquired data to the result object
                result.MWSAuthToken = response.getAuthTokenResult.MWSAuthToken;
                result.MerchantId   = response.getAuthTokenResult.SellerId;

                return(result);
            }
            catch (Exception e)
            {
                //All exceptions are written to MWSAuthToken field to be handled outside this function
                AmazonSecurityInfo result = new AmazonSecurityInfo();
                result.MWSAuthToken = e.Message;

                return(result);
            }
        }
示例#2
0
        public AuthTokenRetriver GetAuthToken(string SellerId)
        {
            // The client application name
            string appName = "C#";

            // The client application version
            string appVersion = "4.0";

            // The endpoint for region service and version (see developer guide)
            string serviceURL = "https://mws.amazonservices.co.uk";

            // Create a configuration object
            MarketplaceWebServiceSellersConfig config = new MarketplaceWebServiceSellersConfig();

            config.ServiceURL = serviceURL;

            // Create the client itself
            var client = new MarketplaceWebServiceSellersClient(appName, appVersion, AccessKey, SecretKey, config);

            //Create the request object
            GetAuthTokenRequest req = new GetAuthTokenRequest();

            req.SellerId = SellerId;

            try
            {
                //Try connecting to server to aquire requested data
                GetAuthTokenResponse response = client.GetAuthTokenStatus(req);
                doRetry           = false;
                this.MWSAuthToken = response.getAuthTokenResult.MWSAuthToken;
                return(this);
            }
            catch (Exception e)
            {
                if (e.Message != "Request is throttled")
                {
                    doRetry = false;
                }
                error = e.Message;
                return(this);
            }
        }