GithubHelp home page GithubHelp logo

smatioli / spark-integration-sample Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ciscodevnet/webex-integration-sample

0.0 1.0 0.0 1.44 MB

an example of Cisco Spark Integration in NodeJS

Home Page: https://learninglabs.cisco.com//labs/collab-spark-intl/step/1

License: MIT License

JavaScript 90.30% HTML 8.66% CSS 1.04%

spark-integration-sample's Introduction

Example of Cisco Spark Integration (OAuth flow) in NodeJS

This Spark Integration example illustrates an OAuth Grant flow at the end of which the Spark User who granted permission will see his full name displayed.

It comes as a companion to the DevNet learning lab: Run a Cisco Spark Integration locally.

This example leverages a pre-registered Spark integration with a Redirect URL on localhost so that it can be run with minimal setup. The flow initiates at http://localhost:8080/, and Cisco Spark Oauth Flow redirects to http://localhost:8080/oauth

In real world, you'll register and deploy your integration on a public URL, check the guide below to register your own integration.

Run the sample locally

git clone https://github.com/CiscoDevNet/spark-integration-sample
cd spark-integration-sample
npm install
DEBUG=oauth* node server.js

You're all set, the integration sample is live! Let's go through the OAuth flow.

Reach to the integration home page from a Web browser: open http://localhost:8080:

Click Start, enter your Spark account email and click accept (or decline):

If you accepted, the Spark integration you're running locally just got issued an "Cisco Spark API access token" that the code can now act on your behalf. The integration custom code logic asks Cisco Spark for your Person details and displays your full name.

Registering your own Spark OAuth Integration

To learn more about Cisco Spark Integration, read the reference documentation.

In the example above, we were running a pre-registered OAuth integration running on port 8080. Let's now register a new Cisco Spark integration that we will be running on port 9090.

Go to Spark for developers portal, click 'Apps', 'add Apps', and then create an integration.

Fill the form fields:

  • Name: your app name, such as 'My Awesome App' in the snapshot below,
  • Description: these details are not displayed to your app end-users,
  • Support email: a valid email address for Cisco Spark operations team to reach to you if necessary,
  • App Icon: an URL pointing to an image with a resolution of 512x512 pixels minimum. Feel free to use this provided sample for now: https://bit.ly/SparkIntegration-512x512
  • Redirect URI: enter http://localhost:9090/oauth since this is the URL at which the provided code sample will be listening on your local machine. More to come in the next steps if this lab
  • Scopes: select the spark:people_read and spark:rooms_read scopes.

Note the list of scopes you selected corresponds to the maximum set of scopes that your integration will be entitled to ask for. However, from code, your integration can dynamically refine the set of scopes asked for in order to comply with the real needs of your application. A good practice is to start small and extend the set of scopes asked for as the end-users gain trust in your app and is ready to ask more advanced features.

Click save, and look for your integration client id and client secret.

Let's now configure the integration: you can either paste your integration client id and secret into the code, or set these as env variables on the command line.

Instructions for Mac, Linux and Windows bash users

  • open a terminal

  • on a single command line, type:

    DEBUG=oauth* PORT=9090 REDIRECT_URI="http://localhost:9090/oauth" CLIENT_ID="YOUR_INTEGRATION_ID" CLIENT_SECRET="YOUR_INTEGRATION_SECRET"  node server.js

Instructions for Windows command shell users

  • open a command shell

  • enter the commands below:

    set DEBUG="oauth*"
    set PORT=9090
    set REDIRECT_URI="http://localhost:9090/oauth"
    set CLIENT_ID="YOUR_INTEGRATION_ID"
    set CLIENT_SECRET="YOUR_INTEGRATION_SECRET"
    node server.js

You're all set. Restart your integration, and give it a try: http://localhost:9090

This step by step guide explained how to register a Spark Integration running on a local developer environment. In the real-world, you will want to deploy your integration, and register its public URL rather than your local machine's. Check the DevNet learning lab: 'Deploy a Cisco Spark Integration' for detailled instructions.

More about Cisco Spark integrations

Spark Apps incarn Cisco Spark’s extensibility.

By creating custom Spark apps, developers can tie together existing software with Cisco Spark and instantly promote their Apps. For example, add the “Jira Integration” to Rooms and your teams will be notified as Jira issues (whether EPIC, Story, Task or Bugs) are updated.

Spark integrations are a way for your apps to request permission to invoke the Spark APIs on behalf of other Spark users. The process used to request permission is called an OAuth Grant Flow, and is documented in the Integrations guide.

You can experiment the flow in DevNet Learning lab “Understand the OAuth Grant flow of Spark Integrations”.

spark-integration-sample's People

Contributors

objectisadvantag avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.