Authentication overview

Cisco Spark, now integrated into the Webex App, provides programmatic access through its API for developers building integrations and custom applications. Authentication for these interactions relies primarily on the OAuth 2.0 framework, ensuring secure and delegated access to user data and organizational resources. This approach allows applications to obtain limited access to a user's account without requiring their direct credentials, enhancing security and user privacy. The Webex API supports various OAuth 2.0 grant types to accommodate different application architectures, from web-based applications to mobile clients and server-side services.

The core principle of Cisco Spark authentication involves an application requesting permission from a user to access their Webex data or perform actions on their behalf. Upon approval, the application receives an access token, which is then used in subsequent API requests as a “bearer” credential. This token-based system enables temporary, revocable access, aligning with modern security practices for API integrations. Organizations leveraging Cisco Spark for unified communications can integrate third-party tools for enhanced collaboration, workflow automation, and data synchronization, all secured through standardized authentication protocols.

Supported authentication methods

The Webex App API, which serves as the programmatic interface for Cisco Spark functionalities, primarily supports OAuth 2.0 for authentication. This widely adopted industry standard allows for secure delegation of access without sharing user credentials directly with the client application. Different OAuth 2.0 grant types are available to suit various application types:

  • Authorization Code Grant: Recommended for web applications and client-side applications with a backend, offering the highest security by exchanging an authorization code for an access token on a secure server.
  • Client Credentials Grant: Suitable for server-to-server interactions where an application needs to access its own service account or resources without a user context.
  • Refresh Tokens: Used in conjunction with authorization codes to obtain new access tokens after the initial one expires, minimizing the need for repeated user re-authentication.

Authentication methods summary

Method When to Use Security Level
OAuth 2.0 (Authorization Code Grant) Web applications, mobile apps, single-page applications (SPAs) High (Recommended for user-facing apps)
OAuth 2.0 (Client Credentials Grant) Server-to-server integrations, background services without user interaction High (Recommended for machine-to-machine apps)
Bearer Tokens (Access Tokens) All API requests after initial OAuth flow High (When properly secured and rotated)

For more detailed information on OAuth 2.0 and its various flows, refer to the official OAuth 2.0 specification.

Getting your credentials

To authenticate with the Webex App API (formerly Cisco Spark API), you will first need to register your application to obtain the necessary OAuth 2.0 credentials:

  1. Register a New Integration: Navigate to the My Apps section on the Webex for Developers portal.
  2. Create a New App: Click “Create a New App” and choose “Integration” for user-facing applications requiring delegated access, or “Bot” for automated agents.
  3. Configure App Details: Provide details such as the app name, description, and importantly, the Redirect URI(s). The Redirect URI is where Webex will send the authorization code after a user grants permission. For web applications, this will be an endpoint on your server; for local development, http://localhost:port can be used.
  4. Define Scopes: Select the specific permissions (scopes) your application needs, e.g., spark:messages_read, spark:rooms_write. Granting only necessary scopes adheres to the principle of least privilege.
  5. Obtain Client ID and Client Secret: After registration, Webex will provide you with a Client ID and Client Secret. These are your application's unique identifiers and should be treated as sensitive information. The Client ID is public, but the Client Secret must be kept confidential and never exposed in client-side code.

For server-to-server applications using the Client Credentials Grant, you will use the Client ID and Client Secret directly to request an access token from the Webex OAuth 2.0 token endpoint, without involving a user interface for authorization. Consult the Webex API Authentication documentation for detailed steps on setting up different grant types.

Authenticated request example

Once you have obtained an OAuth 2.0 access token, you include it in the Authorization header of your HTTP requests. The token type for Webex API is Bearer. Here's an example using JavaScript (Node.js with axios) to list Webex rooms:

const axios = require('axios');

const accessToken = 'YOUR_ACCESS_TOKEN'; // Replace with your actual access token
const apiUrl = 'https://api.webex.com/v1/rooms';

async function listWebexRooms() {
  try {
    const response = await axios.get(apiUrl, {
      headers: {
        'Authorization': `Bearer ${accessToken}`,
        'Content-Type': 'application/json'
      }
    });
    console.log('Webex Rooms:', response.data.items);
  } catch (error) {
    console.error('Error fetching Webex rooms:', error.response ? error.response.data : error.message);
  }
}

listWebexRooms();

In this example:

  • YOUR_ACCESS_TOKEN represents the OAuth 2.0 access token your application received after the authorization flow.
  • The Authorization header contains the Bearer scheme followed by the access token.
  • The request is made to the /v1/rooms endpoint, which requires authenticated access to retrieve a list of rooms the authenticated user is a member of.

Always ensure your access token is securely stored and transmitted. For a complete overview of available endpoints and their specific authentication requirements, refer to the Webex API v1 Overview.

Security best practices

Implementing secure authentication for your Cisco Spark (Webex App) integrations is crucial. Adhering to these best practices helps protect user data and maintain the integrity of your applications:

  • Secure Client Secret Storage: Never embed your Client Secret in client-side code (JavaScript, mobile apps). Store it securely on a server-side component or in environment variables and access it only from your backend.
  • Use HTTPS Everywhere: All communication involving credentials and tokens must occur over HTTPS (TLS/SSL) to prevent eavesdropping and man-in-the-middle attacks. This is a fundamental requirement for OAuth 2.0. The RFC 6749 for OAuth 2.0 explicitly states the necessity of TLS.
  • Short-lived Access Tokens and Refresh Tokens: Configure your application to request and utilize short-lived access tokens. When an access token expires, use a refresh token (if obtained) to get a new one without requiring the user to re-authorize. Store refresh tokens securely, ideally encrypted, and revoke them if compromised.
  • Validate Redirect URIs: Strictly register and validate Redirect URIs. Only allow pre-registered, secure URIs to prevent authorization code interception attacks.
  • Implement State Parameter: Use the state parameter in your OAuth 2.0 authorization requests to prevent Cross-Site Request Forgery (CSRF) attacks. The state parameter should be a unique, unguessable value generated by your application and verified upon redirection.
  • Scope Limitation (Principle of Least Privilege): Request only the minimum necessary scopes (permissions) for your application to function. This limits the potential impact if your application or its tokens are compromised.
  • Error Handling and Logging: Implement robust error handling for authentication failures and log relevant events for auditing and security monitoring. Avoid exposing sensitive information in error messages to users.
  • Regular Token Rotation: Periodically rotate access and refresh tokens, especially for long-lived applications.
  • Monitor for Suspicious Activity: Implement monitoring for unusual login attempts or API usage patterns that could indicate unauthorized access.
  • Stay Updated: Keep your application's dependencies and Webex API SDKs up-to-date to benefit from the latest security patches and features.