BlueConic OAuth 2.0 API

The OAuth 2.0 API allows external applications to be authenticated and authorized to access the public BlueConic API. The OAuth 2.0 specification is implemented according to [RFC 6749](https://www.rfc-editor.org/rfc/rfc6749).

OpenAPI Specification

blueconic-oauth-2-0-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: BlueConic REST API v2 Audit Events OAuth 2.0 API
  description: "Welcome to the [BlueConic](https://www.blueconic.com) REST API v2. Our recently updated APIs offer access to a wealth of resources to interact with BlueConic visitor profiles, segments, interactions, and audit events via OpenAPI and OAuth 2.0 authorization flows making the interconnection between various services more secure, intuitive, and reliable than ever before.\n\nThis page describes how developers can use OAuth 2.0, the industry-standard protocol for authorization, to authorize apps in BlueConic and get started using the BlueConic REST API v2.\n\nLearn more about [how to use the BlueConic REST API v2](https://support.blueconic.com/hc/en-us/articles/200453891-Using-the-BlueConic-REST-API).\n\n# Authorizing an application to use the BlueConic REST API via OAuth 2.0\n\nIf you have an external software application that needs to communicate with BlueConic, you need to allow access to the BlueConic REST API. The authorization process in BlueConic for this access is built to OAuth 2.0 specifications. You can use either of two authorization flows: the authorization code flow and the client credentials flow. The most secure flow is the authorization code flow, intended for use with a user who can log in to BlueConic and authenticate the application to use the BlueConic API. The client credentials flow is easier to implement but lacks security features present in the authorization code flow. The client credentials flow is intended for machine-to-machine applications. \n\n## Using the Authorization code flow\n\nTo use the BlueConic REST API with OAuth 2.0 according to the authorization code flow you need to complete the following steps:\n\n1.  Configure BlueConic so your external OAuth 2.0 application can authenticate and use the REST API. This means that you have to:\n    - Have a BlueConic user with the \"Applications\" permission. This user can configure the details of the external application in BlueConic.\n    - Have a BlueConic user with the \"Authorize Applications\" permission. This user can authorize the external application via the redirect page served by the authorization server.\n    - Configure the external application on the BlueConic Access management > Applications tab, so BlueConic can store public client ID and the client secret. The external app uses these properties to perform the initial request for an authorization code.\n\n\n2. Develop an application that can execute OAuth 2.0 REST API requests. Specifically, that means an application that is able to:\n    - Generate a code verifier and code challenge.\n    - Store the public client ID and client secret as configured in BlueConic (see step 1). \n    - Request an authorization code from the BlueConic authorization server. Include the code challenge in the request. \n    - Show the user the redirect page served by the BlueConic authorization server, so the user can authenticate with credentials and consent to giving the application BlueConic REST API access.\n    - Receive the authorization code from the BlueConic authorization server.\n    - Use the authorization code to request an access token (and refresh token) from the BlueConic authorization server. Include the code verifier in the request. You must also provide the client ID and client secret for client authentication. You can do so by sending the client credentials in the body of your POST request.\n    - Use the access token to perform REST API requests. \n    - Revoke access if the user of the app so chooses (meaning that after this revocation, a new authorization grant is required to use the BlueConic REST API).\n    - Handle refresh token rotation. This means that whenever a new access token is requested using the refresh token, a new refresh token is also supplied along with the new access token.\n    - Handle all possible responses from the BlueConic REST API appropriately.\n\n[Read more about the Authorization Code Flow](https://support.blueconic.com/hc/en-us/articles/14912561861403)\n\n## Using the Client credentials flow\n\nTo make use of the BlueConic REST API with OAuth 2.0 following the client credentials flow, you need to complete the following steps:\n\n1. Configure BlueConic so your external OAuth 2.0 application can use the REST API. This means that you have to:\n    - Have a user with the \"Applications\" permission. This user can configure the details of the external application in BlueConic.\n    - Have a user with the \"Authorize Applications\" permission, who also has all permissions needed to use the REST API endpoint that you intend to use.\n    - Configure the external application on the Access management > Applications tab, so BlueConic can generate and store the public client ID and client secret for client authentication. Also select at least one scope so the app has access to that part of the REST API.\n   \n2. Develop an application that can execute OAuth 2.0 REST API requests. Specifically that means an application that is able to:\n    - Store the public client ID and client secret as configured in BlueConic (see above).\n    - Use the client ID and client secret to request an access token from the BlueConic authorization server. You can do so by sending the client credentials in the body of your POST request.\n    - Use the access token to perform REST API requests.\n    - Handle all possible responses from the BlueConic REST API appropriately.\n\n[Read more about the Client Credentials Flow](https://support.blueconic.com/hc/en-us/articles/14912655111963)\n\n# Using the try-out feature\nThe “Try” feature allows you to directly make REST calls to the API server, where you can make requests and see the responses, allowing you to experiment with the BlueConic API and understand how it works.\n\nYou can enter your BlueConic URL in the “API Servers” section. After that, you can try out the calls that don’t require authentication, such as “Get interactions”. You can enter the request parameters and click “Try”.\n\n## OAuth 2.0 authentication\n\nMost calls require OAuth 2.0 authentication, such as “Get audit events”. This can be seen at the right top and under the Request heading of each API method. To use the “Try” feature, you need to authenticate via OAuth 2.0. First create an Application in your BlueConic tenant (see above). When using the Authorization code flow, make sure to set the redirect URL to this tool as specified under the OAuth 2.0 authentication section. After you create the Application, authenticate this tool in the “Authentication” section. Enter the client ID and client secret in the correct OAuth 2.0 flow for which you created the application and press “GET TOKEN”. If the tool got a token successfully, you will see the text “API key applied” just under the “Authentication” heading. In calls that require Authentication, it will say “OAuth (OAuth 2.0) in header”. Now you can use the “Try” feature for calls that require OAuth 2.0. If you hover over the authentication scheme at the top right of an API method, you will see the required scopes (e.g. “Get audit events” has the scope read:audit-events). Make sure you set these scopes for the Application in BlueConic.\n\n# General functionality for all endpoints\n\n1. By using `prettyPrint`, the JSON data is formatted in a way that makes it easier to read and work with. This can be especially useful when working with large or complex JSON datasets. Add the following to the query string of a request to pretty print JSON: `&prettyPrint=true`.\n2. Gzip encoding is a method of compressing data and is commonly used to reduce the size of files sent over the Internet. BlueConic supports this so a client can set the request header `Accept-Encoding: gzip`. BlueConic will then compress the data in its response and send it back to the client with the `Content-Encoding: gzip` header. \n\n"
  termsOfService: https://www.blueconic.com/blueconic-terms-and-conditions
  contact:
    name: Contact us
    url: https://support.blueconic.com/hc/en-us/requests/new
  license:
    name: BlueConic
    url: https://github.com/blueconic/openapi/blob/main/LICENSE.MD
  version: '100.0'
servers:
- url: https://{blueconicHostname}/rest/v2
  description: The BlueConic server
  variables:
    blueconicHostname:
      description: BlueConic server hostname, e.g. 'tenant.blueconic.net'
      default: tenantname
tags:
- name: OAuth 2.0
  description: The OAuth 2.0 API allows external applications to be authenticated and authorized to access the public BlueConic API. The OAuth 2.0 specification is implemented according to [RFC 6749](https://www.rfc-editor.org/rfc/rfc6749).
paths:
  /oauth/authorize:
    get:
      tags:
      - OAuth 2.0
      summary: Start Authorization Code Flow
      description: Starts the Authorization Code Flow. The user will be redirected to the authorization server where the user can grant or deny the external application access. The Proof Key for Code Exchange ([PKCE](https://www.rfc-editor.org/rfc/rfc7636)) extension is enforced for the Authorization Code Flow.
      operationId: startAuthorizationCodeFlow
      parameters:
      - name: response_type
        in: query
        description: The response type. Currently only supports the authorization code grant type.
        required: true
        schema:
          type: string
          enum:
          - code
        example: code
      - name: client_id
        in: query
        description: The client ID of the external application. The client ID is assigned during client registration.
        required: true
        schema:
          type: string
        example: Zl3QZFUGOKQrABbX2RoGwmgUDOiFAhLq
      - name: redirect_uri
        in: query
        description: The redirect URI to which the user is redirected to after successful authentication. The redirect URI must exactly match the redirect URI provided at client registration.
        required: true
        schema:
          type: string
        example: https://client.example.com/cb
      - name: code_challenge
        in: query
        description: The code challenge for PKCE.
        required: true
        schema:
          type: string
        example: 4MwafmutlwDy7ly8QOtO-bUvSVzU3I_OQEDgmB3Pn5A
      - name: code_challenge_method
        in: query
        description: The code challenge method for PKCE.
        schema:
          type: string
          default: PLAIN
          enum:
          - PLAIN
          - S256
        example: S256
      - name: state
        in: query
        description: An opaque value provided by the client to maintain state between the request and redirect URI. The state value is added to the redirect URI upon redirection.
        schema:
          type: string
        example: xyz
      responses:
        '302':
          description: Redirects to the redirect URI with the error added to the query component of the redirect URI.
        '303':
          description: Redirects to the authorization server.
        '400':
          description: One or more required parameters are missing or invalid.
        '503':
          description: The server is too busy to handle the request.
  /oauth/revoke:
    post:
      tags:
      - OAuth 2.0
      summary: Revoke token
      description: Revokes access and/or refresh tokens.
      operationId: revokeToken
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                token:
                  type: string
                  description: The access or refresh token to revoke.
                client_id:
                  type: string
                  description: The client id is a unique identifier assigned to a client application.
                client_secret:
                  type: string
                  description: The client secret is a confidential string used for authentication in OAuth 2.0.
                token_type_hint:
                  type: string
                  description: A token type hint to optimize token retrieval during revocation. The token type hint will be ignored if it contains an invalid value.
                  enum:
                  - access_token
                  - refresh_token
              required:
              - client_id
              - client_secret
              - token
      responses:
        '200':
          description: Token has been revoked.
        '400':
          description: One or more required parameters are missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenErrorResponse'
              examples:
                Example response:
                  description: Example response
                  value: "{\n  \"error_description\": \"Unsupported grant type\",\n  \"error\": \"unsupported_grant_type\"\n}"
        '401':
          description: Authentication failed (unauthorized).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenErrorResponse'
              examples:
                Example response:
                  description: Example response
                  value: "{\n  \"error_description\": \"Client authentication failed\",\n  \"error\": \"invalid_client\"\n}"
        '503':
          description: The server is too busy to handle the request.
  /oauth/token:
    post:
      tags:
      - OAuth 2.0
      summary: Get token
      description: Obtains an access token and optional refresh token by presenting an authorization grant or refresh token. [Refresh Token Rotation](https://www.rfc-editor.org/rfc/rfc6819#section-5.2.2.3) is supported by default for the Authorization Code Flow.
      operationId: getToken
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                grant_type:
                  type: string
                  description: The grant type.
                  enum:
                  - authorization_code
                  - client_credentials
                  - refresh_token
                client_id:
                  type: string
                  description: The client id is a unique identifier assigned to a client application.
                client_secret:
                  type: string
                  description: The client secret is a confidential string used for authentication in OAuth 2.0.
                code:
                  type: string
                  description: The authorization code, which serves as the grant. Only required when `grant_type=authorization_code`.
                redirect_uri:
                  type: string
                  description: The redirect URI passed in the authorization request. Only required when `grant_type=authorization_code`.
                code_verifier:
                  type: string
                  description: The code verifier for PKCE.
                refresh_token:
                  type: string
                  description: The refresh token with which to obtain a new access and refresh token. Only required when `grant_type=refresh_token`.
              required:
              - client_id
              - client_secret
              - grant_type
      responses:
        '200':
          description: Returns an access token and optional refresh token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenSuccessResponse'
              examples:
                Example response:
                  description: Example response
                  value: "{\n  \"access_token\": \"2YotnFZFEjr1zCsicMWpAA\",\n  \"refresh_token\": \"tGzv3JOkF0XG5Qx2TlKWIB\",\n  \"token_type\": \"Bearer\",\n  \"expires_in\": 3600\n}"
        '400':
          description: One or more required parameters are missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenErrorResponse'
              examples:
                Example response:
                  description: Example response
                  value: "{\n  \"error_description\": \"Unsupported grant type\",\n  \"error\": \"unsupported_grant_type\"\n}"
        '401':
          description: Authentication failed (unauthorized).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenErrorResponse'
              examples:
                Example response:
                  description: Example response
                  value: "{\n  \"error_description\": \"Client authentication failed\",\n  \"error\": \"invalid_client\"\n}"
        '503':
          description: The server is too busy to handle the request.
components:
  schemas:
    TokenSuccessResponse:
      type: object
      properties:
        access_token:
          type: string
          description: The access token that gives access to the public API.
        expires_in:
          type: integer
          format: int32
          description: The time in seconds after which the access token will expire.
        refresh_token:
          type: string
          description: The refresh token with which a new access and refresh token can be obtained.
        token_type:
          type: string
          description: The token type of the access and refresh token.
    TokenErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: The error code.
        error_description:
          type: string
          description: A human-readable description of the error with additional information.
  securitySchemes:
    oauth2:
      type: oauth2
      description: 'Authenticates a registered OAuth 2.0 client. The Authorization code flow and Client credentials flow are supported. Make sure to select the correct flow based on which flow the registered client supports. The client id and client secret can be found in BlueConic by opening the registered client under *Settings* > *Access management* > *Applications*.<br/>**NOTE:** When using the Authorization code flow, the redirect URL of the registered client in BlueConic must be set to `https://rest.apidoc.blueconic.com/oauth-receiver.html` and ''Send Proof Key for Code Exchange'' must be enabled.<br/><br/>To use a Bearer token for authentication, follow these steps: <br/>1. Acquire the token through authentication.<br/>2. Include the token in the request''s Authorization header as Bearer \<token\>.<br/>3. Send the request to access protected resources.<br/>4. Handle token expiration by refreshing or obtaining a new token.'
      flows:
        clientCredentials:
          tokenUrl: /rest/v2/oauth/token
        authorizationCode:
          authorizationUrl: /rest/v2/oauth/authorize
          tokenUrl: /rest/v2/oauth/token
          refreshUrl: /rest/v2/oauth/token