Authentication

API calls to Compute Classic require basic authentication (user name and password). You can pass your username and password with every API call or you can pass a valid authentication token. To get a valid authentication token, send an HTTP request to authenticate the user credentials. If the authentication request succeeds, the server returns a cookie containing an authentication token that is valid for 30 minutes. The client making the API calls must include this cookie in the API calls.

To request for an authentication token and store the authentication token in an environment variable:

  1. Note down the user name and password for your Compute Classic instance, which is case-sensitive. The account creation email from Oracle contains this information. If you don't have this information, contact your service administrator.

  2. Identify the type of cloud account that you are using: Traditional Cloud Accounts (also known as Cloud Service Accounts) or Cloud Accounts with Identity Cloud Service (IDCS). See Types of Oracle Cloud Accounts in Getting Started with Oracle Cloud.

    Note:

    • Oracle Cloud Machine only supports Cloud Accounts with Identity Cloud Service (IDCS).

    • The user name and password for your Compute Classic instance is case-sensitive.

  3. While making REST API calls, you have to pass a two-part user name. Specify the two-part user name in one of the following ways.

    • If you are using a traditional cloud account or if your account creation email contains information about the identity domain as shown in the following example, then you must use the following format for the two-part user name:

      /Compute-identityDomainName/username

      Account creation email from Oracle contains the name of the identity domain, user name, and password.

      For example, if your identity domain is acme and the username in your account-creation email is jack.jones@example.com, then use the following two-part user name for REST API calls:

      /Compute-acme/jack.jones@example.com

    • If you are using a cloud account with Identity Cloud Service (IDCS) or if your account creation email does not contain information about the identity domain, then you must use the following format for the two-part user name:

      /Compute-serviceInstanceID/username

      To get the service instance ID for your Compute Classic instance:

      1. Sign in to the Oracle Cloud My Services application. See Signing in to Your Cloud Account in Getting Started with Oracle Cloud.

        The Oracle Cloud My Services Dashboard page is displayed. It lists the services that are assigned to your account.

      2. In the Compute service tile, click Compute. The Service Details page for Compute Classic is displayed.

      3. Under Additional Information, note down the Service Instance ID.

      For example, if your service instance ID is 575260584 and the username in your account-creation email is jack.jones@example.com, then use the following two-part user name for REST API calls:

      /Compute-575260584/jack.jones@example.com

    Note:

    All examples in this document use /Compute-acme/jack.jones@example.com as the two-part user name. If you are using a Cloud Account with IDCS, replace acme in the two-part user name with your service instance ID.

  4. Get an authentication cookie from Compute Classic, as shown in the following cURL command example:

    curl -i -X POST
         -H "Content-Type: application/oracle-compute-v3+json"
         -d '{"user":"/Compute-acme/jack.jones@example.com","password":"ft7)Dvjo"}'
            https://api-z999.compute.us0.oraclecloud.com/authenticate/
    

    Enter the command on a single line. Line breaks are used in this example for readability.

    • acme and jack.jones@example.com are example values. Replace acme with the identity domain ID of your Compute Classic account, and jack.jones@example.com with your user name.

    • api-z999.compute.us0.oraclecloud.com is an example REST endpoint URL. Change this value to the REST endpoint URL of your Compute Classic site. For information about finding out REST endpoint URL for your site, see Send Requests.

  5. In the response to the POST request, look for the Set-Cookie header, as shown in the following example.

    Set-Cookie: nimbula=eyJpZGVudGl0eSI6ICJ7XCJyZWFsbVwiOiBcImNvbXB1dGUtdXM2LXoyOFwiLCBcInZhbHVlXCI6IFwie1xcXCJjdXN0b21lclxcXCI6IFxcXCJDb21wdXRlLWFjbWVjY3NcXFwiLCBcXFwicmVhbG1cXFwiOiBcXFwiY29tcHV0ZS11czYtejI4XFxcIiwgXFxcImVudGl0eV90eXBlXFxcIjogXFxcInVzZXJcXFwiLCBcXFwic2Vzc2lvbl9leHBpcmVzXFxcIjogMTQ2MDQ4NjA5Mi44MDM1NiwgXFxcImV4cGlyZXNcXFwiOiAxNDYwNDc3MDkyLjgwMzU5MiwgXFxcInVzZXJcXFwiOiBcXFwiL0NvbXB1dGUtYWNtZWNjcy9zeWxhamEua2FubmFuQG9yYWNsZS5jb21cXFwiLCBcXFwiZ3JvdXBzXFxcIjogW1xcXCIvQ29tcHV0ZS1hY21lY2NzL0NvbXB1dGUuQ29tcHV0ZV9PcGVyYXRpb25zXFxcIiwgXFxcIi9Db21wdXRlLWFjbWVjY3MvQ29tcHV0ZS5Db21wdXRlX01vbml0b3JcXFwiXX1cIiwgXCJzaWduYXR1cmVcIjogXCJRT0xaeUZZdU54SmdjL3FuSk16MDRnNmRWVng2blY5S0JpYm5zeFNCWXJXcVVJVGZmMkZtdjhoTytaVnZwQVdURGpwczRNMHZTc2RocWw3QmM0VGJpSmhFTWVyNFBjVVgvb05qd2VpaUcyaStBeDBPWmc3SDJFSjRITWQ0S1V3eTl6NlYzRHd4eUhwTjdqM0w0eEFUTDUyeVpVQWVQK1diMkdzU1pjMmpTaHZyNi9ibU1CZ1Nyd2M4MUdxdURBMFN6d044V2VneUF1YVk5QTUxZmxaanJBMGVvVUJudmZ6NGxCUVVIZXloYyt0SXZVaDdUcGU2RGwxd3RSeFNGVVlQR0FEQk9xMExGaVd1QlpaU0FTZVcwOHBZcEZ2a2lOZXdPdU9LaU93dFc3VkFtZ3VHT0E1Yk1ibzYvMm5oZEhTWHJhYmtsY000UVE1LzZUMDJlZUpTYVE9PVwifSJ9; Path=/; Max-Age=1800
    

    Note that the Set-Cookie header and value are in a single line. Line breaks are used in this example for readability.

  6. Store the authentication cookie in an environment variable, as shown in the following example for a Linux host.

    Note that the entire command is in a single line. Line breaks are used in this example for readability.

    export COMPUTE_COOKIE='nimbula=eyJpZGVudGl0eSI6ICJ7XCJyZWFsbVwiOiBcImNvbXB1dGUtdXM2LXoyOFwiLCBcInZhbHVlXCI6IFwie1xcXCJjdXN0b21lclxcXCI6IFxcXCJDb21wdXRlLWFjbWVjY3NcXFwiLCBcXFwicmVhbG1cXFwiOiBcXFwiY29tcHV0ZS11czYtejI4XFxcIiwgXFxcImVudGl0eV90eXBlXFxcIjogXFxcInVzZXJcXFwiLCBcXFwic2Vzc2lvbl9leHBpcmVzXFxcIjogMTQ2MDQ4NjA5Mi44MDM1NiwgXFxcImV4cGlyZXNcXFwiOiAxNDYwNDc3MDkyLjgwMzU5MiwgXFxcInVzZXJcXFwiOiBcXFwiL0NvbXB1dGUtYWNtZWNjcy9zeWxhamEua2FubmFuQG9yYWNsZS5jb21cXFwiLCBcXFwiZ3JvdXBzXFxcIjogW1xcXCIvQ29tcHV0ZS1hY21lY2NzL0NvbXB1dGUuQ29tcHV0ZV9PcGVyYXRpb25zXFxcIiwgXFxcIi9Db21wdXRlLWFjbWVjY3MvQ29tcHV0ZS5Db21wdXRlX01vbml0b3JcXFwiXX1cIiwgXCJzaWduYXR1cmVcIjogXCJRT0xaeUZZdU54SmdjL3FuSk16MDRnNmRWVng2blY5S0JpYm5zeFNCWXJXcVVJVGZmMkZtdjhoTytaVnZwQVdURGpwczRNMHZTc2RocWw3QmM0VGJpSmhFTWVyNFBjVVgvb05qd2VpaUcyaStBeDBPWmc3SDJFSjRITWQ0S1V3eTl6NlYzRHd4eUhwTjdqM0w0eEFUTDUyeVpVQWVQK1diMkdzU1pjMmpTaHZyNi9ibU1CZ1Nyd2M4MUdxdURBMFN6d044V2VneUF1YVk5QTUxZmxaanJBMGVvVUJudmZ6NGxCUVVIZXloYyt0SXZVaDdUcGU2RGwxd3RSeFNGVVlQR0FEQk9xMExGaVd1QlpaU0FTZVcwOHBZcEZ2a2lOZXdPdU9LaU93dFc3VkFtZ3VHT0E1Yk1ibzYvMm5oZEhTWHJhYmtsY000UVE1LzZUMDJlZUpTYVE9PVwifSJ9; Path=/; Max-Age=1800'

After getting an authentication cookie, you can perform operations on Compute Classic objects.