Basic Workflow

Follow

The following code examples are in Ruby.

Step 1 - Set up a client oauth library

< your consumer key > and < your consumer secret > can be found at https://youraccount.bime.io/oauth/applications

@client ||= OAuth2::Client.new(< your consumer key >,< your consumer secret >,
                               :site => 'https://youraccount.bime.io/',
                               :parse_json => true
)

Step 2 - Authorize your application to access resources of your Bime account

Get the URL to authorize your app

auth_url = @client.auth_code.authorize_url(:redirect_uri => "http://yourapplication/redirect_url")

Redirect browser to the authorization page

redirect_to auth_url

On a classic workflow, after authorizing the application, you will be redirected to your application with an authorization code (in params[:code])

Step 3 - Code behind http://yourapplication/redirect_url

if(params[:code])
  # Exchange the authorization code with an access token (used in future calls to access resources)
  @access_token = @client.auth_code.get_token(params[:code], :redirect_uri => "http://yourapplication/redirect_url")
  # Setup the API endpoint
  @client.site = "https://api.bime.io"
end

Step 4 - Make an API call

resp = @access_token.get "/v3/dashboards/" + dashboard_id
dashboard = JSON.parse(resp.body)["result"]
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk