Git Product home page Git Product logo

amazon-sellingpartner-api's Introduction

Selling Partner API Authentication/Authorization Library

This library provides helper classes for use when signing HTTP requests for Amazon Selling Partner APIs. It is intended for use with the Selling Partner API Client Libraries generated by swagger codegen using the RestSharp library. It can also be integrated into custom projects.

LWAAuthorizationSigner

Obtains and signs a request with an access token from LWA (Login with Amazon) for the specified endpoint using the provided LWA credentials.

Example

using RestSharp;
using Amazon.SellingPartnerAPIAA;

string resource = "/my/api/path";
RestClient restClient = new RestClient("https://...");
IRestRequest restRequest = new RestRequest(resource, Method.GET);

// Seller APIs
LWAAuthorizationCredentials lwaAuthorizationCredentials = new LWAAuthorizationCredentials
{
    ClientId = "...",
    ClientSecret = "",
    RefreshToken = "",
    Endpoint = new Uri("...")
};

/* Sellerless APIs
The Selling Partner API scopes can be retrieved from the ScopeConstants class and used to specify a list of scopes of an LWAAuthorizationCredentials instance. */
LWAAuthorizationCredentials lwaAuthorizationCredentials = new LWAAuthorizationCredentials
{
    ClientId = "...",
    ClientSecret = "",
    Scopes = new List<string>() { ScopeConstants.ScopeNotificationsAPI, ScopeConstants.ScopeMigrationAPI }
    Endpoint = new Uri("...")
};

restRequest = new LWAAuthorizationSigner(lwaAuthorizationCredentials).Sign(restRequest);  

Note the IRestRequest reference is treated as mutable when signed.

AWSSigV4Signer

Signs a request with AWS Signature Version 4 using the provided AWS developer account credentials.

Example

using RestSharp;
using Amazon.SellingPartnerAPIAA;

string resource = "/my/api/path";
RestClient restClient = new RestClient("https://...");
IRestRequest restRequest = new RestRequest(resource, Method.GET);

AWSAuthenticationCredentials awsAuthenticationCredentials = new AWSAuthenticationCredentials 
{
    AccessKeyId = "..."
    SecretKey = "..."
    Region = "..."
};

restRequest = new AWSSigV4Signer(awsAuthenticationCredentials)
    .Sign(restRequest, restClient.BaseUrl.Host);

Note the IRestRequest reference is treated as mutable when signed.

Resources

This package features Mustache templates designed for use with swagger codegen. When you build Selling Partner API Swagger models with these templates, they help generate a rich SDK with functionality to invoke Selling Partner APIs built in. The templates are located in resources/swagger-codegen.

Building

This package is built as a .NET Standard Library via a Visual Studio Solution with implementation and test projects. The Visual Studio Community Edition can be obtained for free from Microsoft and used to build the solution and generate a .dll assembly which can be imported into other projects.

Dependencies

All dependencies can be installed via NuGet

  • RestSharp - 105.1.0
  • Newtonsoft.Json 12.0.3
  • NETStandard.Library 2.0.3 (platform-specific implementation requirements are documented on the Microsoft .NET Guide)

License

Swagger Codegen templates are subject to the Swagger Codegen License.

All other work licensed as follows:

Copyright 2020 Amazon.com, Inc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this library except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

amazon-sellingpartner-api's People

Contributors

cxiaoao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.