Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clearer auth #89

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions src/pages/firefly-api/guides/concepts/authentication/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ hideBreadcrumbNav: true

Learn how to make requests to Firefly APIs

<InlineAlert variant="info" slots="text" />

If you don't already have a Firefly "client ID" and "client secret", retrieve them from your [Adobe Developer Console project](https://developer.adobe.com/developer-console/docs/guides/services/services-add-api-oauth-s2s/#api-overview) before reading further. **Securely store these credentials and never expose them in client-side or public code.**

## 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)](https://www.adobe.com/content/dam/cc/en/trust-center/ungated/whitepapers/corporate/adobe-identity-management-services-security-overview.pdf) 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](https://developer.adobe.com/developer-console/docs/guides/services/services-add-api-oauth-s2s/#api-overview) 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:

```bash
export FIREFLY_CLIENT_ID=PASTE_YOUR_CLIENT_ID_HERE
export FIREFLY_CLIENT_SECRET=PASTE_YOUR_CLIENT_SECRET_HERE
export FIREFLY_CLIENT_ID=asdf...123
export FIREFLY_CLIENT_SECRET=qwer...456
```

Next, run the following command to generate an access token:
Expand All @@ -74,4 +74,43 @@ The response will look like this:

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.

Now that you are retrieving an access token, hop over to the [Quickstart Guide](../../index.md) to generate your first image!
Export your access token as an environment variable:

```bash
export FIRELY_ACCESS_TOKEN=asdf...1234
```

## Generate an image

Next, call the [Firefly Generate Images API](../../api/image_generation/V3/):

```bash
curl --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:

```json
{
"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"
}
```
4 changes: 2 additions & 2 deletions src/pages/firefly-api/guides/concepts/seed-id/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ If you don't already have a Firefly "client ID" and "access token", learn how to
First, open a secure terminal and `export` your "client ID" and "access token" as environment variables:

```bash
export FIREFLY_CLIENT_ID=PASTE_YOUR_CLIENT_ID_HERE
export FIREFLY_ACCESS_TOKEN=PASTE_YOUR_ACCESS_TOKEN
export FIREFLY_CLIENT_ID=asdf...123
export FIREFLY_ACCESS_TOKEN=qwer...456
```

Next, run the following `curl` command to generate an image:
Expand Down
4 changes: 2 additions & 2 deletions src/pages/firefly-api/guides/concepts/styles/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ If you don't already have a Firefly "client ID" and "access token", learn how to
First, open a secure terminal and `export` your "client ID" and "access token" as environment variables:

```bash
export FIREFLY_CLIENT_ID=PASTE_YOUR_CLIENT_ID_HERE
export FIREFLY_ACCESS_TOKEN=PASTE_YOUR_ACCESS_TOKEN
export FIREFLY_CLIENT_ID=asdf...123
export FIREFLY_ACCESS_TOKEN=qwer...456
```

Next, run this command:
Expand Down
6 changes: 3 additions & 3 deletions src/pages/firefly-api/guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ If you don't already have a Firefly "client ID" and "access token", learn how to
Open a secure terminal and `export` your "client ID" and "access token" as environment variables:

```bash
export FIREFLY_CLIENT_ID=PASTE_YOUR_CLIENT_ID_HERE
export FIREFLY_ACCESS_TOKEN=PASTE_YOUR_ACCESS_TOKEN
export FIREFLY_CLIENT_ID=asdf...123
export FIREFLY_ACCESS_TOKEN=qwer...456
```

### 2. Call the Firefly Generate Images API

Next, call the [Firefly Generate Images API](./api/image_generation/V3/) with the `access_token` and `CLIENT_ID`:
Next, call the [Firefly Generate Images API](./api/image_generation/V3/):

```bash
curl --location 'https://firefly-api.adobe.io/v3/images/generate' \
Expand Down
Loading