Hub per sviluppatoriStato dell'APISupporto

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:

NomeDescrizioneObbligatorio
clientIdYour LWA client identifier. For more information, refer to Viewing your developer information.
clientSecretYour LWA client secret. For more information, refer to Viewing your developer information.
refreshTokenThe 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 refreshToken if the operation that you call in the following step requires selling partner authorization. All operations that are not grantless operations require selling partner authorization. If you include refreshToken, do not include withScopes.

withScopes

The scope of the LWA authorization grant. Takes the value ScopeNotificationsAPI for the Notifications API.

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.
endpointL'URI del server di autenticazione LWA.

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();

Questa pagina ti è stata utile?