Authenticating to and Calling the REST API

Before calling a REST API, you must authenticate your session, which involves generating access, refresh and session tokens. The REST API client uses these tokens when you call the REST API server.

You must use the Password Method to be able to authenticate and call REST APIs.
  1. To generate access tokens for SaaS in your API client, use the POST method and the following URL:

    https://<tenant-name>.cyberresprod.com/osp/a/<tenant-name>/auth/oauth2/grant
    Your <tenant-name> is part of the URL. For example, extremelyfocused is the tenant name in the following URL: https://extremelyfocused.cyberresprod.com/osp/a/extremelyfocused/auth/oauth2/grant

    Select and specify Header and Body information as follows, where:

    Authorization

    • Authorization type as Basic

    • Client_ID:Client_Secret as base64 encoded

    • Use the client ID and secret that you created when you set up access to the REST APIs.

    Header

    • Content-Type as application/x-www-form-urlencoded
    • Accept as application/json
        
      • Authorization as Basic

    Body

    • Enter grant_type as password
    • Enter Username as User ID
    • Enter password as the password of the UserID
    The server replies with the access_token, the expires_in number of seconds for the access_token validity, and a refresh_token to generate a new access token when the access token expires. To understand how to generate a new access token using the refresh_token, see Refreshing Access Tokens.


    For example:

    Server Request -

    curl --location --request POST 'https://aa.cyberresprod.com/osp/a/extremelyfocused/auth/oauth2/grant' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --header 'Accept: application/json' \
    --header 'Authorization: Basic Q2xpZW50SWQ6Q2xpZW50U2VjcmV0' \
    --data-urlencode 'grant_type=password' \
    --data-urlencode 'username=samantha.landry@extremelyfocused.com' \
    --data-urlencode 'password=samanthapassword'
    

    Server Response -

    {
    "access_token":"eyJ0eXAiOiJhdCtqd3QiLCJhbGciOiJSUzI1NiIsImtpZCI6IkhCb2JINGNtS012Tld1TC1hZWNtSWNJajNFTSJ9.eyJpc3MiOiJodHRwczovL2FhLm1maWNzaWVkZXYuY29tL29zcC9hL1NFQ09QU1ROMDEvYXV0aC9vYXV0aDIiLCJleHA
    iOjE2OTcwMzIwODUsIm5iZiI6MTY5NzAyODQ4NSwiaWF0IjoxNjk3MDI4NDg1LCJqdGkiOiJpeGZUQUZEWlJILXdsbTUzcUQwMWln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zQNRAXwfWvAcqi3yLhCRxC
    kRIFu_ND2im-MTpviqa4-ZM4UBw_XqLP9o1DjLsbZJCnAMbf8"
    }
  2. To generate a session token using the access token in your API client, use the method GET and the following URL:

    https://<arcsight-saas>​​​/mgmt/api/users/me/details
    
    

    where <arcsight-saas>​​​​ represents your ArcSight SaaS product

    For example:

    https://extremelyfocused.mp.cyberresprod.com​​/mgmt/api/users/me/details

    Select and specify Header information as follows:

    Authorization

    • Authorization type as Bearer
    • Use the Access token generated in step 1

    For example:

    curl -v --location --request GET 'https://extremelyfocused.mp.cyberresprod.com/mgmt/api/users/me/details' \
    --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG
    4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
  3. Review the documentation for REST API endpoints.

  4. Access your REST API endpoint with the session token generated in step 2 as a cookie.

    For example, to search all the dashboards owned by the logged in user ID, and the dashboards that are being shared with the logged in user ID’s role, you might use the following content:

    curl --location --request GET 'https://extremelyfocused.mp.cyberresprod.com/metadata/api/v1/dashboards' \
    --header 'Cookie: SESSIONTOKEN=1E4C45F0B8DC821FF251EC17558B1ABF'