For the complete documentation index, see llms.txt. This page is also available as Markdown.

Delegated Authentication

Delegated authentication allows your application to identify an ecoinvent user and determine which ecoinvent data they are licensed to access without handling their credentials directly.

Instead of managing ecoinvent usernames and passwords, your application redirects users to the ecoinvent login page. After they authenticate and grant consent, you receive a token you can use to query the API on their behalf and retrieve their license and access entitlements.

Delegated authentication must be explicitly enabled for your account. Contact us to request access before getting started.

How It Works

The integration uses the OAuth 2.0 Authorization Code Flow. At a high level:

  1. Your app redirects the user to the ecoinvent login page

  2. The user authenticates and consents to your app linking their account

  3. ecoinvent redirects back to your app with a short-lived authorization code

  4. Your server exchanges that code for an access token

  5. You use the access token to call the ecoinvent API and retrieve the user's licence and data entitlements

Prerequisites

1. Request feature enablement

Contact the ecoinvent team to have delegated authentication enabled for your account. Once enabled, your credentials will be available in the accounts portal.

2. Retrieve your credentials

Go to accounts portal to find:

Credential
Description

client_id

Your application's unique identifier

client_secret

Your application's secret key - never expose this in client-side code or public repositories

3. Configure your application

Also in accounts portal, set the following fields. These are displayed to the user on the ecoinvent consent screen:

Field
Description

App Name

Display name shown to users (e.g. MyApp)

App Description

Short description of why your app needs access

Logo URI

HTTPS URL of your app's logo shown on the consent screen

Redirect URIs

The URLs in your app that ecoinvent redirects to after login. Must match exactly in every request, wild cards are accepted.

Endpoints

All endpoints are on the ecoinvent SSO server:

Endpoint
URL

Authorization

https://sso.ecoinvent.org/realms/ecoinvent/protocol/openid-connect/auth

Token

https://sso.ecoinvent.org/realms/ecoinvent/protocol/openid-connect/token

Revoke

https://sso.ecoinvent.org/realms/ecoinvent/protocol/openid-connect/revoke

The Flow

Step 1 - Redirect the user to ecoinvent

Construct the authorization URL and redirect the user's browser to it:

Parameter
Description

response_type

Must be code

client_id

Your client ID from accounts.ecoinvent.org

redirect_uri

Must exactly match your registered URI (URL-encoded)

state

A random value you generate. Returned after login, verify it matches to prevent CSRF attacks

Step 2 - User authenticates and consents

On the ecoinvent SSO page, the user logs in and is shown a consent screen with your app's name, logo, and description. They approve the connection between their ecoinvent account and your application.

Users only see the consent screen the first time they authorize your app, or after revoking access. On subsequent logins they are redirected immediately.

Step 3 - Exchange the authorization code for tokens

After consent, ecoinvent redirects to your redirect_uri with a code:

Verify the state value matches what you sent before continuing.

Then exchange the code for tokens from your server:

Response:

Field
Description

access_token

Short-lived token (typically 5 minutes) used to call the ecoinvent API

expires_in

Seconds until the access token expires

refresh_token

Long-lived token used to obtain new access tokens without re-authenticating

The ecoinvent SSO is an OpenID Connect (OIDC) server, so the access token is a signed JWT. You can decode it directly to read claims such as username, useful for surfacing the linked account identity in your UI. Alternatively, call the userinfo endpoint for a canonical JSON representation:

Step 4 - Query the user's license and data access

Use the access token to call the ecoinvent API and retrieve what data the user is entitled to access based on their license:

The /versions endpoint returns a list of accessible releases. Each entry includes the version name, public release date and system model:

Use this to gate access in your application, only offer dataset versions and system models that appear in the response for the authenticated user.


Refreshing Tokens

Access tokens expire after a few minutes. Use the refresh token to obtain a new one without requiring the user to log in again:

The response includes a new access_token and a new refresh_token. Always store the latest refresh token returned.

If the refresh request fails with a 400 error, the refresh token has expired and the user must re-authorize from Step 1.


Revoking Tokens (Logout)

When a user disconnects your app, revoke their tokens to terminate the session on the ecoinvent side:


Security Checklist

  • Never expose client_secret in client-side JavaScript, mobile app binaries, or public repositories

  • Always validate state on the callback to prevent CSRF attacks

  • Use HTTPS for your redirect URI in production

  • Store tokens securely, access tokens in memory, refresh tokens in server-side storage

  • Revoke tokens on disconnect, don't just discard them client-side

Last updated

Was this helpful?