Generare un token bearer di autorizzazione da utilizzare nelle API REST di Anypoint Platform
Questo articolo KB funziona se il nome utente dell'account è escluso dalla MFA, se la MFA è obbligatoria l'articolo non funziona.
Se l'organizzazione ha implementato la gestione dell'identità esterna (SSO/SAML), seguire la procedura Obtaining an API Bearer Token Using a SAML Assertion (Ottenere un token bearer API tramite un'asserzione SAML).
Se si preferisce utilizzare un utente non federato, seguire la procedura descritta in questo articolo.
Come descritto nella documentazione dell'API Anypoint Access Management, è anche possibile ottenere un token bearer utilizzando client_id e client_secret dell'organizzazione o dell'ambiente CloudHub tramite OAuth2.
Tuttavia, questo token è utile principalmente per gli scopi di API Manager e non è associato a un utente, quindi non può essere utilizzato per chiamare la maggior parte delle API (ad esempio CloudHub).
Se per l'utente è abilitata la MFA, non è possibile utilizzare il seguente metodo per ottenere un token utilizzando nome utente/password. Vedere Creating connected app and getting the bearer token example (Esempio di creazione di un'app connessa e di recupero del token bearer) oppure How to Get the Anypoint Authorization Access or Bearer Token from Chrome Browser Session (Come ottenere l'autorizzazione di accesso o il token bearer Anypoint dalla sessione del browser Chrome).
Vedere i seguenti commenti CURL.
In Mac, sostituire e :
curl -H "Content-Type: application/json" -X POST -d '{"username":"<NOMEUTENTE>","password":"<PASSWORD>"}' "https://anypoint.mulesoft.com/accounts/login"
In Linux, sostituire mio-utente e mia-password con il nome utente e la password effettivi per CloudHub, quindi eseguire il comando:
curl -d 'username=mio-utente&password=mia-password' https://anypoint.mulesoft.com/accounts/login
In Windows, utilizzare:
curl -sq 'https://anypoint.mulesoft.com/accounts/login' -H "Content-Type: application/json" -d "{\"username\": \"mio-utente\",\"password\": \"mia-password\"}"
Verrà generato un output JSON, in cui dovrebbe essere visualizzato un token di accesso, che sarà valido per almeno 60 minuti, a seconda della configurazione dell'account.
Se si desidera, è possibile ottenere l'ID organizzazione da utilizzare in altre chiamate API CloudHub. Nel comando seguente sostituire mio-token con il token bearer del comando precedente, quindi eseguire il comando:
curl -sq 'https://anypoint.mulesoft.com/accounts/api/me' -H 'Authorization: Bearer mio-token'
Tenere presente che questo metodo di accesso all'API Anypoint cesserà con l'introduzione del requisito della MFA per tutti gli utenti di MuleSoft Anypoint Platform.
001115323

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.