Skip to content

procore/Procore-Sample-ROR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

Setup Instructions

The following steps are instructions to launch and view a simple Ruby on Rails application that authenticates with Procore's API using the OAuth 2.0 Authorization Code Grant Type flow. The application uses the Procore Ruby SDK and Omniauth strategy to simplify authentication and requests to the Procore API. It can be configured to access either Procore's production environment or Procore's developer sandbox environment.

THIS REPOSITORY IS FOR TRAINING PURPOSES ONLY.

  1. Clone this repository
  2. Run bundle install
  3. Run bundle exec figaro install
  4. Installing the figaro gem will create an untracked file: config/application.yml

Within this file, configure your application's Client ID, Client Secret, and Redirect URI in order to save these as the application's environment variables:

    * CLIENT_ID: ''
    * CLIENT_SECRET: ''
    * REDIRECT_URI: 'http://localhost:3000/auth/procore/callback'
    * OAUTH_URL: 'https://login.procore.com'
    * BASE_URL: 'https://api.procore.com'

* CLIENT_ID and CLIENT_SECRET values are provided when [creating an application](https://developers.procore.com/documentation/new-application) in the Procore Developer Portal.
* The REDIRECT_URI's domain should match the domain of your application, and the full path must be added as an authorized redirect uri for your app in the developer portal.
* The BASE_URL and the OAUTH_URL will depend on which environment you're accessing. If you're working in the production environment, the OAUTH_URL will be https://login.procore.com and the BASE_URL will be https://login.procore.com. For the sandbox environment, both the OAUTH_URL and the BASE_URL should be set to https://sandbox.procore.com.
* After these values have been configured within the `application.yml` file, make sure to save your changes.
  1. Navigate to the directory where the repository was cloned to and launch your Rails server.
  2. The landing page will include a button that says, "Sign In to Procore". Click this button and enter your Procore email address/password.
  3. After authenticating with Procore, you will be redirected back to the sample application. This page will include a table containing the first and last five characters of both your access token and your refresh token. In addition, there will be timestamps corresponding to when the access token was generated and when it expires (2 hours after generation).
  4. To access the data returned by the Show User Info endpoint, click on the "Show User Information" button on the home page.
  5. To refresh your access token, click on the "Refresh Access Token" button. Notice that the corresponding values will be updated in the table on the home page.

If you have any questions regarding this application's code or functionality, please reach out to apisupport@procore.com.