SAP-archive / analytics-cloud-apis-oauth-client-sample

Sample embedding SAP Analytics Cloud (SAC) in to third party websites using the SAC API
Other
12 stars 4 forks source link
oauth-client sample sap-analytics-cloud sap-blogs

Important Notice

This public repository is read-only and no longer maintained.

SAP Analytics Cloud API Demo App

This repository contains the accompanying source code for the blog post SAP Analytics Cloud APIs: Getting Started Guide (available on SAP Blogs or GitHub). We exemplify how third-party applications can access SAC content by using the authorization protocol OAuth 2.0.

This demo app is programmed in Node.js and uses the simple-oauth2 library.

Project Structure

Requirements

  1. To run the express- app locally, you need to install Node.js on your computer.
  2. Furthermore, you need to have access to an SAP Analytics Cloud system.

Download

  1. Please clone the repository: git clone https://github.com/SAP/analytics-cloud-apis-oauth-client-sample.git.
  2. Download all necessary npm packages by running npm install from the command line in your project root folder.

Configuration

The entire configuration is explained in our user guide (SAP Blogs/ GitHub). Below you can find a brief summary of the configuration process. We reference the sections of the user guide.

Configuration of the SAC Tenant

  1. Please make sure to have enabled iframe embedding on your tenant (cf. 2.1. Enable iFrame Embedding).
  2. Please make sure to have registered the demo app as OAuth client in SAC (cf. 1.1. Client Registration and 1.2.1. Registration Details).

Configuration of the Application

To start using the application, it needs to be configured.

  1. For one, you have to configure the server program. Please define the configuration in the file config.properties.
    1. Enter the client ID for your OAuth client. It has to be the ID you defined in SAC's administration page (cf. 1.1. Client Registration).
    2. Enter the secret you specified in SAC (cf. 1.2.1. Registration Details).
    3. Enter the token & authorization URL (cf. 1.2.2. Obtaining the Access Token).
    4. Enter the redirect URI (cf. 1.2.1. Registration Details).
  2. For two, you have to configure the client program. Please define the configuration in the file config.js.
    1. Enter your tenant's URL and ID (cf. 2.2. Compose the URL).
    2. [Optional] Enter demo display parameters (cf. 2.2.1. Display Parameters).
    3. [Optional] Enter demo filter parameters (cf. 2.2.2. Filter Parameters).
    4. [Optional] Enter demo variable parameters (cf. 2.2.3. Variable Parameters).

Usage

  1. As can be seen from the source code in server-app.js, the application runs on localhost:8080. Please start the server (e.g., in the folder analytics-cloud-apis-oauth-client-sample execute the console command npm start or node server-app).
  2. Navigating to localhost:8080 in your Google Chrome browser, opens the login page.
  3. Clicking on login sends you to the authorization server’s authorization endpoint.
  4. After entering your user credentials for the Identity Provider (IdP), please click on authorize to get an access token. Once you have the access token, you can access protected resources on SAC. SAC's default IdP is the SAP Cloud Platform Identity Authentication Service.
  5. Please enter parameter values (or, if specified, choose demo parameters by clicking on Demo Parameters). The tooltip next to a parameter provides an explanation for the corresponding parameter. It may also be helpful to read 2. SAC URL API.
  6. After having entered parameter values, click on Generate URL. In the text area above of the iframe, you see the URL that has been generated.
  7. Click on Load URL to visualize the SAC story within the iframe.

Troubleshooting

In case the story is not visualized in the iframe (i.e., the iframe's background remains white), it is very likely that some cookies have been blocked. Make sure to have allowed cookies for the domain of your IdP. If necessary, allow additional cookies by clicking on the cookies-icon in Chrome's address bar.

Support

Should you have any problems, please create a new issue.

Contributions

Currently we do not accept any external contributions to this project.

License

Copyright (c) 2017 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under SAP SAMPLE CODE LICENSE AGREEMENT, v. 1.0 except as noted otherwise in the LICENSE file.