OAuth-1 and OAuth-2 with Creo

In this tutorial we’ll create a simple Twitter reader (using the HTTPClient class and OAuth-1) and a Google Drive browser (using OAuth-2). Up until Creo b6 all these HTTPClient parameters cannot be dynamically accessed from the code so they must be statically set from the configuration panel. Just a couple of beta versions and we’ll extend dynamic properties to all the classes.

Twitter and OAuth-1

  • Create a new Twitter App from https://apps.twitter.com/
  • Fill-in the fields with your app’s data. The Callback URL must be a valid HTTP URL and the callback locking option must be disabled to allow custom callback URLs in the requests.
  • Get the Consumer Key and the Consumer Secret.
  • In Creo, create a new HTTPClient instance with the Twitter parameters and the Consumer Key/Secret just obtained.
  • Create a new request from HTTPClient instance (right click on HTTPClient1). Twitter offers a lot of API, in this example we’ll list the tweets from a user (https://dev.twitter.com/rest/reference/get/statuses/user_timeline).
  • Finally, add a TableView and set your HTTP request as the DataSet.

You can download a sample project from: http://media.creolabs.com/examples/Twitter.zip

Google Drive and OAuth-2

  • Create (if you don’t have one) a Google account and access the following url: https://console.developers.google.com
  • Create a new project and enable the API you want to use (Google Drive API in this case).
  • Configure the OAuth consent screen with the details of your app.
  • Create Credentials (OAuth client ID).
  • Use the following parameters:
    Application Type: iOS
    Name: your app name
    Bundle ID: the identifier of your app configured in the Application inspector in Creo
  • In order to be able to test the requests inside Creo you have to add another credentials for the Creo simulator with the following parameters:
    Name: CreoApp
    Bundle ID: com.creolabs.creo
  • In Creo, create a new HTTP Client with the following parameters:
  • Create a new request for this HTTP Client, for example to list the Google Drive file (API documentation: https://developers.google.com/drive/v3/reference/files/list#request):
  • In order to customize your request, you could also configure the optional query parameters.
  • Add a Table View and set your HTTP request as the DataSet.

  • Enjoy your Google Drive inside Creo 🙂

You can download a sample project from: http://media.creolabs.com/examples/Google.zip

Leave a Reply

Your email address will not be published. Required fields are marked *