Authentication
Learn how to make requests to Firefly APIs
Overview
Every request made to Firefly APIs must include an encrypted access token. Your secure, server-side application retrieves an access token by making a request to the Adobe Identity Management System (IMS) with your "client ID" and "client secret".
Retrieve your "client ID" and "client secret"
If you don't already have a Firefly "client ID" and "client secret", retrieve them from your Adobe Developer Console project before reading further. Securely store these credentials and never expose them in client-side or public code.
Retrieve an access token
First, open a secure terminal and export
your "client ID" and "client secret" as environment variables so that your later commands can access them:
Copied to your clipboardexport FIREFLY_CLIENT_ID=asdf...123export FIREFLY_CLIENT_SECRET=qwer...456
Next, run the following command to generate an access token:
Copied to your clipboardcurl --location 'https://ims-na1.adobelogin.com/ims/token/v3' \--header 'Content-Type: application/x-www-form-urlencoded' \--data-urlencode 'grant_type=client_credentials' \--data-urlencode "client_id=$FIREFLY_CLIENT_ID" \--data-urlencode "client_secret=$FIREFLY_CLIENT_SECRET" \--data-urlencode 'scope=openid,AdobeID,session,additional_info,read_organizations,firefly_api,ff_apis'
The response will look like this:
Copied to your clipboard{"access_token":"asdf...1234","token_type":"bearer","expires_in":86399}
Notice how the response includes an expires_in
field, which informs you of how many more seconds the access token is valid for. Each access token is valid for 24 hours, after which your secure server-side application will need to request a new token. A best practice is securely store the token and refresh it before it expires.
Export your access token as an environment variable:
Copied to your clipboardexport FIRELY_ACCESS_TOKEN=asdf...1234
Generate an image
Next, call the Firefly Generate Images API:
Copied to your clipboardcurl --location 'https://firefly-api.adobe.io/v3/images/generate' \--header 'Content-Type: application/json' \--header 'Accept: application/json' \--header "x-api-key: $FIREFLY_CLIENT_ID" \--header "Authorization: Bearer $FIREFLY_ACCESS_TOKEN" \--data '{"prompt": "a realistic illustration of a cat coding"}'
The response will look like this:
Copied to your clipboard{"size": {"width": 2048,"height": 2048},"outputs": [{"seed": 1779323515,"image": {"url": "https://pre-signed-firefly-prod.s3-accelerate.amazonaws.com/images/asdf-12345?lots=of&query=params..."}}],"contentClass": "art"}