Request

Response

    Task 1 – Obtain an Access Token

    This task generates an access token for authenticating subsequent API calls in the walkthrough. The token requires a specific scope to grant access to necessary resources. In Step 3, replace the placeholder <REQUIRED_SCOPE> with data:read data:create data:write code:all to obtain an access token with a sufficient scope for the rest of this walkthrough.

    By the end of this task, you will know how to obtain a two-legged access token when the Client ID and Client Secret are known.

    You use the following operation for this task:

    OperationHTTP Request
    Get an Access Token POST /token

    Step 1 - Register an App

    Follow the instructions in the tutorial Create an app to register an app for this tutorial. Note down the Client ID and Client Secret you receive for the app. When specifying details of the app, don’t change the APIs selected by default under API Access.

    Step 2: Encode your Client ID and Client Secret

    Before requesting an access token, you’ll need to encode your credentials in a special format to ensure the data you send is secure. This is how you do it:

    1. Concatenate your Client ID and Client Secret with a colon character (:) in between, as shown below.

      <CLIENT_ID>:<CLIENT_SECRET>
      
    2. Use the appropriate function or method in your preferred programming language to encode the combined string to the Base64 format. Examples:

      Programming LanguageMethod/Function
      JavaScript btoa() function
      Python b64encode() function from the base64 module
      C# Convert.ToBase64String() method
      const clientId =  "<CLIENT_ID>";
      const clientSecret =  "<CLIENT_SECRET>";
      const clientAuthKeys =  btoa(clientId +":"+clientSecret);
      
      import base64
      
      clientId = "<CLIENT_ID>"
      clientSecret = "<CLIENT_SECRET>"
      clientAuthKeys = base64.b64encode((clientId + ":" + clientSecret).encode("ascii")).decode("ascii")
      
      using System;
      using System.Text;
      
      string clientId = "<CLIENT_ID>";
      string clientSecret = "<CLIENT_SECRET>";
      string combinedKeys = clientId + ":" + clientSecret;
      byte[] bytesToEncode = Encoding.UTF8.GetBytes(combinedKeys);
      string encodedText = Convert.ToBase64String(bytesToEncode);
      
      Show More

      Note: There are online tools that you can use to convert the combined string to a Base64 encoded string. However, we don’t recommend that you use such tools. Exposing your Client ID and Client Secret to an online tool can pose a security threat.

      You should receive a string that looks like RjZEbjh5cGVtMWo4UDZzVXo4SVgzcG1Tc09BOTlHVVQ6QVNOa3c4S3F6MXQwV1hISw==.

    Step 2: Use encoded string to obtain an Access Token

    Call POST token:

    The Base64 encoded Client ID + Client Secret are passed through the Authorization header. The grant_type and scope are specified as form fields in the request body.

    Request

    curl -v 'https://developer.api.autodesk.com/authentication/v2/token' \
       -X 'POST' \
       -H 'Content-Type: application/x-www-form-urlencoded' \
       -H 'Accept: application/json' \
       -H 'Authorization: Basic <BASE64_ENCODED_STRING_FROM_STEP_1>' \
       -d 'grant_type=client_credentials' \
       -d 'scope=<REQUIRED_SCOPE>'
    

    Response

    HTTP/1.1 200 OK
    Cache-Control: no-cache, no-store, no-store
    Content-Type: application/json;charset=UTF-8
    Date: Mon, 20 Feb 2017 04:46:41 GMT
    Expires: Thu, 01 Jan 1970 00:00:00 GMT
    max-age: Thu, 01 Jan 1970 00:00:00 GMT
    Pragma: no-cache
    Server: Apigee Router
    Set-Cookie: PF=2xeh6LTdKKqibsTu9HlyM5;Path=/;Secure;HttpOnly
    X-Frame-Options: SAMEORIGIN
    Content-Length: 436
    Connection: keep-alive
    
    {
      "token_type": "Bearer",
      "expires_in": 1799,
      "access_token": "<ACCESS_TOKEN>"
    }
    
    Show More

    Notes:

    • Note down the access token (indicated by <ACCESS_TOKEN>) in the response. You will use this value to authenticate all subsequent requests in this tutorial.
    • The access token expires in the number of seconds specified by the expires_in attribute.
     
    ______
    icon-svg-close-thick

    Cookie preferences

    Your privacy is important to us and so is an optimal experience. To help us customize information and build applications, we collect data about your use of this site.

    May we collect and use your data?

    Learn more about the Third Party Services we use and our Privacy Statement.

    Strictly necessary – required for our site to work and to provide services to you

    These cookies allow us to record your preferences or login information, respond to your requests or fulfill items in your shopping cart.

    Improve your experience – allows us to show you what is relevant to you

    These cookies enable us to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we use to deliver information and experiences tailored to you. If you do not allow these cookies, some or all of these services may not be available for you.

    Customize your advertising – permits us to offer targeted advertising to you

    These cookies collect data about you based on your activities and interests in order to show you relevant ads and to track effectiveness. By collecting this data, the ads you see will be more tailored to your interests. If you do not allow these cookies, you will experience less targeted advertising.

    icon-svg-close-thick

    THIRD PARTY SERVICES

    Learn more about the Third-Party Services we use in each category, and how we use the data we collect from you online.

    icon-svg-hide-thick

    icon-svg-show-thick

    Strictly necessary – required for our site to work and to provide services to you

    Qualtrics
    W
    Akamai mPulse
    W
    Digital River
    W
    Dynatrace
    W
    Khoros
    W
    Launch Darkly
    W
    New Relic
    W
    Salesforce Live Agent
    W
    Wistia
    W
    Tealium
    W
    Upsellit
    W
    CJ Affiliates
    W
    Commission Factory
    W
    Google Analytics (Strictly Necessary)
    W
    Typepad Stats
    W
    Geo Targetly
    W
    SpeedCurve
    W
    Qualified
    #

    icon-svg-hide-thick

    icon-svg-show-thick

    Improve your experience – allows us to show you what is relevant to you

    Google Optimize
    W
    ClickTale
    W
    OneSignal
    W
    Optimizely
    W
    Amplitude
    W
    Snowplow
    W
    UserVoice
    W
    Clearbit
    #
    YouTube
    #

    icon-svg-hide-thick

    icon-svg-show-thick

    Customize your advertising – permits us to offer targeted advertising to you

    Adobe Analytics
    W
    Google Analytics (Web Analytics)
    W
    AdWords
    W
    Marketo
    W
    Doubleclick
    W
    HubSpot
    W
    Twitter
    W
    Facebook
    W
    LinkedIn
    W
    Yahoo! Japan
    W
    Naver
    W
    Quantcast
    W
    Call Tracking
    W
    Wunderkind
    W
    ADC Media
    W
    AgrantSEM
    W
    Bidtellect
    W
    Bing
    W
    G2Crowd
    W
    NMPI Display
    W
    VK
    W
    Adobe Target
    W
    Google Analytics (Advertising)
    W
    Trendkite
    W
    Hotjar
    W
    6 Sense
    W
    Terminus
    W
    StackAdapt
    W
    The Trade Desk
    W
    RollWorks
    W

    Are you sure you want a less customized experience?

    We can access your data only if you select "yes" for the categories on the previous screen. This lets us tailor our marketing so that it's more relevant for you. You can change your settings at any time by visiting our privacy statement

    Your experience. Your choice.

    We care about your privacy. The data we collect helps us understand how you use our products, what information you might be interested in, and what we can improve to make your engagement with Autodesk more rewarding.

    May we collect and use your data to tailor your experience?

    Explore the benefits of a customized experience by managing your privacy settings for this site or visit our Privacy Statement to learn more about your options.