Example #1
0
 public override Task <GetAuthTokenResponse> GetAuthToken(GetAuthTokenRequest request, ServerCallContext context)
 {
     return(Task.FromResult(
                new GetAuthTokenResponse
     {
         Header = HeaderBuilder.Build(request.Header, new CommonError {
             Code = CommonError.Types.Code.Ok
         }),
         Status = GetAuthTokenResponse.Types.Status.Ok,
         Token = new HMACMD5().ComputeHash(System.Text.Encoding.UTF8.GetBytes(request.Username + request.Password)).ToString()
     }));
 }
Example #2
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);
            }
        }
Example #3
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);
            }
        }
Example #4
0
 public GetAuthTokenResponse GetAuthTokenStatus(GetAuthTokenRequest request)
 {
     return(connection.Call(
                new MarketplaceWebServiceSellersClient.Request <GetAuthTokenResponse>("GetAuthToken", typeof(GetAuthTokenResponse), servicePath),
                request));
 }