Use Token Authentication With Embedded Oracle Analytics Cloud Content

Use token authentication when you want to authenticate users to Oracle Analytics Cloud in the background, but don't want to use 3-Legged OAuth.

When you authenticate embedded Oracle Analytics content with tokens, client-side session cookies aren't created. This can prevent third-party-cookie restrictions from blocking embedded content. Your content can be displayed without reconfiguring browsers or configuring Oracle Analytics to use a vanity URL in the same domain as the host embedding site. This benefit applies only to JavaScript framework embedding, not to embedding by workbook URL.

Note:

Export to Excel doesn't work correctly when you use token authentication with embedded Oracle Analytics Cloud content.

OAuth 2.0 Token Authentication

This authentication type requires a bearer token. Go to the Access Tokens tab on your Profile page to find the required token. See Obtain OAuth 2.0 Access Tokens for Oracle Analytics Cloud.

Note:

You must obtain the token with a user context. This means you can't use some grant types, such as the Client Credentials grant type, with embedded content.

Update the HTML page to allow for proper token authentication. For information about how to generate tokens, see Securing Authorizations in Oracle Cloud.

JavaScript Embedding Framework V2

With V2, don't add the deprecated TOKEN=true parameter to the embedding.js script URL. After the V2 embedding framework is ready, use setEmbeddingConfig() to configure token authentication. Specify a tokenAuthFunction that returns either a token string or a Promise that resolves to a token string.

  1. Load the V2 embedding script. Select the embedding mode that matches the host application. For example, use standalone for an application that doesn't use Oracle JET.
  2. When oracle.oa.embedding.ready() resolves, call setEmbeddingConfig() and specify token as the security configuration type.
  3. Apply bindings after the security configuration is set.

Example

This example uses an API to obtain the token. If your HTML page uses an API to obtain the token, then you must make the required API available.

Here project-path specifies the workbook's repository path.

<!DOCTYPE html>
<html dir="ltr">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Standalone DV Embed Demo Using Token</title>

  <script
    src="https://<instance>.analytics.ocp.oraclecloud.com/public/dv/v2/embedding/auto/embedding.js"
    type="application/javascript">
  </script>
</head>
<body>
  <b>Standalone embedded workbook test</b>

  <div style="width: calc(50% - 40px); height: 50%; border: 1px solid black; padding: 10px;">
    <oracle-dv
      project-path="/@Catalog/Shared Folders/Embed/Embed Samples"
      active-page="insight"
      active-tab-id="1">
    </oracle-dv>
  </div>

  <script>
    function getToken() {
      return fetch("/api/analytics-token")
        .then(function (response) {
          if (!response.ok) {
            throw new Error("Unable to obtain an Oracle Analytics access token.");
          }
          return response.text();
        });
    }

    oracle.oa.embedding.ready().then(function (application) {
      application.setEmbeddingConfig({
        oSecurityConfig: {
          sType: "token",
          tokenAuthFunction: getToken
        }
      });

      application.applyBindings();
    });
  </script>
</body>
</html>