AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Integrating the Adobe Firefly Services API: OAuth IMS Authentication, Automated Asset Generation, and Generative Expand

Eli Kent-Daggett · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Relying on designers to click "Generative Expand" in desktop Photoshop is an operational dead end for enterprise digital marketing. When an e-commerce platform refreshes 5,000 product banners or an omnichannel marketing campaign requires asset distribution across Instagram Stories (9:16), desktop display ads (16:9), marketplace square listings (1:1), and high-impact hero banners (21:9), manual desktop editing collapses under its own weight. Designers spend entire shifts marquee-selecting canvases, typing prompt hints, waiting 30 seconds for local rendering, picking one of three variations, and exporting files manually.

At 365Finds, we view generative AI not as a desktop toy for individual retouching, but as programmatic backend infrastructure. Adobe recognized this operational bottleneck by opening up Adobe Firefly Services—a cloud-native REST suite that brings commercial-grade generative models directly into headless CI/CD, DAM, and CMS pipelines.

Yet moving from desktop Photoshop to the Adobe Firefly Services API is rarely frictionless. Engineering teams routinely stumble over Adobe IMS (Identity Management System) OAuth 2.0 handshakes, misconfigured authorization scopes, ephemeral storage upload IDs, and asynchronous polling lifecycles. This guide details how to implement a resilient backend pipeline that automates asset creation and Generative Expand at scale.


The Core Problem: Why Desktop Generative Expand Cannot Scale

Desktop AI tools were built for creative exploration, not high-volume production. Consider an omnichannel campaign across five major digital ad networks. A single master creative asset must be adapted into six aspect ratios, localized into eight languages, and populated with regional background variants. That single creative brief demands 240 rendered assets.

If a senior production artist spends an average of 4 minutes per asset adjusting canvas bounds, running Generative Expand, evaluating fills, saving PSDs, and exporting web-ready assets, the project consumes 16 hours of purely mechanical labor. Scale that across 20 weekly seasonal campaigns, and the workflow becomes an expensive, bottlenecked mess.

Furthermore, desktop workflows break data governance. There is no automated lineage tracking, no standardized seed logging, and no API-level integration with enterprise Digital Asset Management (DAM) platforms like Adobe Experience Manager, Cloudinary, or AWS S3.

The Adobe Firefly Services API eliminates this manual drag. A headless script or microservice can receive a raw master product shot, push it to cloud storage, dispatch parallel Generative Expand requests for all targeted aspect ratios, retrieve the rendered outputs, and commit them directly to an enterprise storage bucket—all within seconds and without a single human click.


Architecture of Adobe Firefly Services: S2S Authentication

Unlike typical consumer AI endpoints that require only a static secret key in an HTTP header, Adobe Firefly Services relies on enterprise-grade Adobe IMS (Identity Management System) architecture. Access requires a two-legged OAuth 2.0 Server-to-Server (S2S) credential exchange.

+--------------------------------------------------------------------+
|                        Client Application                          |
+--------------------------------------------------------------------+
       |                                              |
       | 1. POST /ims/token/v3                        | 3. POST /v3/images/expand
       |    (client_id, client_secret, scope)         |    (x-api-key + Bearer token)
       v                                              v
+-------------------------------+             +----------------------+
|    Adobe IMS Auth Service     |             | Adobe Firefly API    |
+-------------------------------+             +----------------------+
       |                                              |
       | 2. Returns Access Token                      | 4. Returns Presigned
       |    (24-hour validity)                        |    S3 Asset URLs
       v                                              v
+--------------------------------------------------------------------+
|                  Token Cache (Redis / In-Memory)                   |
+--------------------------------------------------------------------+

1. Developer Console Configuration

To initiate API access, you must configure a project within the Adobe Developer Console:

  1. Create a new project within your Adobe Enterprise organization.
  2. Select Add API and choose Firefly Services.
  3. Generate an OAuth Server-to-Server credential.
  4. Extract three critical values: your Client ID (which doubles as your API Key), your Client Secret, and your authorized enterprise organization ID.

2. Token Exchange Protocol

Adobe IMS tokens are requested via a POST request to https://ims-na1.adobelogin.com/ims/token/v3 using application/x-www-form-urlencoded encoding.

curl --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'

A successful response yields a JSON payload containing a 24-hour bearer token:

{
  "access_token": "eyJhbGciOiJSUzI1NiIsIng1dSI6...",
  "token_type": "bearer",
  "expires_in": 86399
}

3. Engineering Pitfalls in IMS Authentication

At 365Finds, our integration tests revealed three common architectural bugs in production deployments:

Production pipelines should maintain an in-memory cache or Redis store for the token, refreshing it proactively when less than 15 minutes of lifetime remain.


Automated Text-to-Image Generation (/v3/images/generate)

Before expanding existing assets, pipelines often generate baseline visual content from structured campaign briefs. Adobe Firefly Services provides /v3/images/generate (synchronous) and /v3/images/generate-async (for queued high-volume jobs).

Standard Generation Payload

POST https://firefly-api.adobe.io/v3/images/generate
Headers:
  Content-Type: application/json
  Accept: application/json
  x-api-key: <FIREFLY_CLIENT_ID>
  Authorization: Bearer <ACCESS_TOKEN>

{
  "prompt": "Professional studio product photography of a modern wireless headphone on an acrylic pedestal, warm cinematic lighting, shallow depth of field, 8k resolution",
  "contentClass": "photo",
  "numVariations": 1,
  "size": {
    "width": 2048,
    "height": 2048
  },
  "visualIntensity": 5
}

Response Parsing

The synchronous endpoint returns rendered variations immediately:

{
  "size": {
    "width": 2048,
    "height": 2048
  },
  "outputs": [
    {
      "seed": 91823741,
      "image": {
        "url": "https://pre-signed-firefly-prod.s3-accelerate.amazonaws.com/images/510aabb4-e154...?AWSAccessKeyId=..."
      }
    }
  ],
  "contentClass": "photo"
}

Crucially, the returned S3 URL is pre-signed and temporary. Your ingestion pipeline must immediately fetch this binary stream and persist it to internal permanent storage. Treating Adobe pre-signed URLs as permanent links will break your product assets within hours.


Headless Generative Expand: Implementation Guide

Generative Expand allows an existing image to be outpainted into larger dimensions or alternate aspect ratios while maintaining visual coherence, lighting consistency, and perspective.

In the Adobe Firefly Services architecture, expanding an image involves two decoupled steps: uploading the source asset to Adobe's binary storage engine to acquire an uploadId, and then invoking the expand endpoint.

+------------------+         +--------------------------+         +-----------------------+
|  Local / Cloud   |         |   Adobe Storage API      |         |  Firefly Expand API   |
|   Source Image   |         | (/v2/storage/image)      |         | (/v3/images/expand)   |
+------------------+         +--------------------------+         +-----------------------+
         |                                |                                   |
         | 1. Stream Binary Asset         |                                   |
         |------------------------------->|                                   |
         |                                | 2. Returns 7-Day uploadId         |
         |                                |----------------->                 |
         |                                                   |                |
         | 3. Dispatch Expand Request with uploadId + Target Dimensions       |
         |------------------------------------------------------------------->|
         |                                                                    |
         | 4. Returns Expanded Asset with Seamlessly Outpainted Boundaries    |
         |<-------------------------------------------------------------------|

Step 1: Upload Source Image to Firefly Storage

The Firefly API accepts images either through a publicly accessible pre-signed URL or an internal uploadId. When dealing with proprietary or unreleased product photography behind corporate firewalls, uploading directly to the Firefly binary storage endpoint is the preferred approach.

curl --location 'https://firefly-api.adobe.io/v2/storage/image' \
--header "Authorization: Bearer ${FIREFLY_ACCESS_TOKEN}" \
--header "x-api-key: ${FIREFLY_CLIENT_ID}" \
--header 'Content-Type: image/jpeg' \
--header 'Accept: application/json' \
--data-binary '@/path/to/hero-product-square.jpg'

The response returns an array containing the resource ID:

{
  "images": [
    {
      "id": "7b583210-9ec1-4b72-8850-13f990e76cd2"
    }
  ]
}

Note: Storage IDs remain valid in Adobe's cluster for 7 days. This allows multiple expand or fill jobs across diverse aspect ratios to reuse the same uploaded base asset without redundant binary re-transfers.

Step 2: Dispatched Canvas Expansion (/v3/images/expand)

With the uploadId secured, dispatch the expansion request to /v3/images/expand.

Suppose our source image is a square (2048×2048) hero shot of a luxury watch, and we need an ultra-wide banner (3840×1600) for a desktop website header. We want the watch positioned on the left side of the canvas, allowing negative space on the right for marketing copy.

POST https://firefly-api.adobe.io/v3/images/expand
Headers:
  Content-Type: application/json
  Accept: application/json
  x-api-key: <FIREFLY_CLIENT_ID>
  Authorization: Bearer <ACCESS_TOKEN>

{
  "prompt": "A modern polished concrete luxury boutique showroom table, soft bokeh background, ambient architectural lights",
  "size": {
    "width": 3840,
    "height": 1600
  },
  "image": {
    "source": {
      "uploadId": "7b583210-9ec1-4b72-8850-13f990e76cd2"
    }
  },
  "placement": {
    "alignment": {
      "horizontal": "left",
      "vertical": "center"
    }
  }
}

Controlling Placement: Alignment vs. Inset

The placement object provides two mutually exclusive positioning models:

Placement ModeParametersBest Use Case
alignmenthorizontal: "left" | "center" | "right"; vertical: "top" | "center" | "bottom"Fast conversion between standard aspect ratios (e.g., placing square product shots in center for 16:9, or left-aligned for hero banners with copy).
insetleft, top, right, bottom (integer pixel offsets from frame edges)Strict layout specifications where exact pixel margins must be reserved for interface overlays or safe zones.

Critical Constraint: The placement block cannot be combined with custom mask payloads. If your pipeline generates a custom alpha mask for inpainting alongside expansion, canvas positioning must be pre-composited in your input asset.


Production Pipeline Implementation in Node.js

Below is a complete, modular TypeScript/JavaScript service illustrating authentication caching, binary storage upload, and generative expansion:

import axios from 'axios';
import fs from 'fs';

class AdobeFireflyClient {
  constructor(clientId, clientSecret) {
    this.clientId = clientId;
    this.clientSecret = clientSecret;
    this.token = null;
    this.tokenExpiresAt = 0;
  }

  async getAccessToken() {
    const now = Math.floor(Date.now() / 1000);
    // Proactively refresh if less than 5 minutes remain
    if (this.token && this.tokenExpiresAt - now > 300) {
      return this.token;
    }

    const params = new URLSearchParams({
      grant_type: 'client_credentials',
      client_id: this.clientId,
      client_secret: this.clientSecret,
      scope: 'openid,AdobeID,session,additional_info,read_organizations,firefly_api,ff_apis'
    });

    const response = await axios.post(
      'https://ims-na1.adobelogin.com/ims/token/v3',
      params.toString(),
      { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
    );

    this.token = response.data.access_token;
    this.tokenExpiresAt = now + response.data.expires_in;
    return this.token;
  }

  async uploadAsset(filePath, mimeType = 'image/jpeg') {
    const token = await this.getAccessToken();
    const fileStream = fs.createReadStream(filePath);
    const stats = fs.statSync(filePath);

    const response = await axios.post(
      'https://firefly-api.adobe.io/v2/storage/image',
      fileStream,
      {
        headers: {
          'Authorization': `Bearer ${token}`,
          'x-api-key': this.clientId,
          'Content-Type': mimeType,
          'Content-Length': stats.size,
          'Accept': 'application/json'
        },
        maxBodyLength: Infinity,
        maxContentLength: Infinity
      }
    );

    return response.data.images[0].id;
  }

  async expandImage({ uploadId, targetWidth, targetHeight, prompt, alignment }) {
    const token = await this.getAccessToken();

    const payload = {
      prompt: prompt || '',
      size: { width: targetWidth, height: targetHeight },
      image: {
        source: { uploadId }
      },
      placement: {
        alignment: alignment || { horizontal: 'center', vertical: 'center' }
      }
    };

    const response = await axios.post(
      'https://firefly-api.adobe.io/v3/images/expand',
      payload,
      {
        headers: {
          'Authorization': `Bearer ${token}`,
          'x-api-key': this.clientId,
          'Content-Type': 'application/json',
          'Accept': 'application/json'
        }
      }
    );

    return response.data.outputs[0].image.url;
  }
}

Hardening the Production Pipeline

Deploying generative workflows into enterprise production environments requires handling real-world infrastructural bottlenecks:

1. Handling HTTP 429 and Rate Limits

Adobe Firefly Services enforces concurrency and rate limits based on your enterprise tier agreement. When your pipeline pushes concurrent requests beyond quota thresholds, the API returns HTTP 429 Too Many Requests.

Resilient clients must inspect the Retry-After response header, apply exponential backoff with randomized jitter, and dispatch requests through a managed worker queue (such as BullMQ on Redis or AWS SQS). Never execute unbounded Promise.all() loops across thousands of assets.

2. Async vs. Sync Decision Thresholds

While /v3/images/expand provides synchronous responses convenient for prototyping, production pipelines processing assets larger than 2K resolution should standardize on /v3/images/expand-async.

The asynchronous endpoint immediately returns HTTP 202 Accepted alongside a job tracking URL. Workers poll the job endpoint at configured intervals (e.g., every 2 to 3 seconds), freeing HTTP gateway connections from timing out during complex diffusion calculations.

3. Commercial Safety and IP Indemnification

The principal reason enterprise architects select Adobe Firefly over open-source alternatives like Stable Diffusion or proprietary platforms like Midjourney is legal and commercial compliance.

Adobe Firefly models are trained exclusively on licensed Adobe Stock content, openly licensed works, and public domain materials where copyright has expired. Adobe backs its Firefly Services with enterprise IP indemnification clauses, protecting brands from copyright infringement claims arising from generated or expanded visual assets. For global marketing teams, this legal certainty outweighs the raw syntactic simplicity of consumer AI wrappers.


365Finds Institutional Evaluation

Adobe Firefly Services is an industrial pipeline tool, not a playful developer sandbox. Its authentication handshake is rigid, requiring multi-attribute IMS server-to-server tokens that feel archaic compared to modern API key headers. Its two-phase storage upload workflow forces developers to build deliberate asset lifecycle managers, and its pre-signed output URLs demand immediate persistence infrastructure.

Yet for organizations generating tens of thousands of compliant campaign derivatives each quarter, there is no viable alternative. The ability to programmatically execute Generative Expand across arbitrary canvas ratios while maintaining enterprise indemnification transforms creative production from a manual human bottleneck into scalable code.


References