Connessione all'API per i partner di vendita utilizzando un Java SDK generato
Come connettersi all'SP-API utilizzando un Java SDK generato.
Before your application can connect to the Selling Partner API, you must register it, and it must be authorized by a selling partner. Refer to Registering your application and Authorizing Selling Partner API applications.
These instructions show you how to use a generated Java SDK to make calls. The SDK exposes classes for configuring your Login with Amazon (LWA) credentials and uses them to generate LWA tokens and sign requests for you. For more information, refer to Generating a Java SDK with LWA token exchange.
Passaggio 3. Configura le tue credenziali LWA
Crea un'istanza di LWAAuthorizationCredentials
, utilizzando i seguenti parametri:
Nome | Descrizione | Obbligatorio |
---|---|---|
clientId | Your LWA client identifier. For more information, refer to Viewing your developer information. | Sì |
clientSecret | Your LWA client secret. For more information, refer to Viewing your developer information. | Sì |
refreshToken | The LWA refresh token. Get this value when the selling partner authorizes your application. For more information, refer to Authorizing Selling Partner API applications. | No. Include |
withScopes | The scope of the LWA authorization grant. Takes the value | No. Include withScopes if the operation that you call in the following step is a grantless operation. If you include withScopes , do not include refreshToken. |
endpoint | L'URI del server di autenticazione LWA. | Sì |
Esempio di operazioni di chiamata che richiedono l'autorizzazione del partner di vendita:
import com.amazon.SellingPartnerAPIAA.LWAAuthorizationCredentials;
LWAAuthorizationCredentials lwaAuthorizationCredentials = LWAAuthorizationCredentials.builder()
.clientId("myClientId")
.clientSecret("myClientSecret")
.refreshToken("Aztr|...")
.endpoint("https://api.amazon.com/auth/o2/token")
.build();
Esempio di chiamata alle operazioni senza concessione:
import com.amazon.SellingPartnerAPIAA.LWAAuthorizationCredentials;
import static com.amazon.SellingPartnerAPIAA.ScopeConstants.SCOPE_NOTIFICATIONS_API;
import static com.amazon.SellingPartnerAPIAA.ScopeConstants.SCOPE_MIGRATION_API;
LWAAuthorizationCredentials lwaAuthorizationCredentials =
LWAAuthorizationCredentials.builder()
.clientId("myClientId")
.clientSecret("myClientSecret")
.withScopes(SCOPE_NOTIFICATIONS_API, SCOPE_MIGRATION_API)
.endpoint("https://api.amazon.com/auth/o2/token")
.build();
Passaggio 3. Crea un'istanza dell'API Sellers e chiama un'operazione
Con il tuo LWAAuthorizationCredentials
istanze configurate è possibile creare un'istanza di SellersApi
e chiama un'operazione.
Esempio:
SellersApi sellersApi = new SellersApi.Builder()
.lwaAuthorizationCredentials(lwaAuthorizationCredentials)
.endpoint("https://sellingpartnerapi-na.amazon.com")
.build();
Updated 6 months ago