Skip to content

Instantly share code, notes, and snippets.

@yshmarov
Created July 24, 2024 17:01
Show Gist options
  • Save yshmarov/8858d6a05c94db61fa0de2caa44f688a to your computer and use it in GitHub Desktop.
Save yshmarov/8858d6a05c94db61fa0de2caa44f688a to your computer and use it in GitHub Desktop.
def authenticate_and_get_companies
host = "https://api.procore.com"
client_id = "foo"
client_secret = "bar"
procore_account = ProcoreAccount.create!(access_token: nil, refresh_token: nil, expires_at: nil)
token = Procore::Auth::ClientCredentials.new(
client_id: client_id,
client_secret: client_secret,
host: host
).refresh
procore_account.update!(access_token: token.access_token, refresh_token: token.refresh_token, expires_at: token.expires_at)
store = Procore::Auth::Stores::ActiveRecord.new(object: procore_account)
client = Procore::Client.new(
client_id: client_id,
client_secret: client_secret,
store: store
)
client.get("companies").body
end
@yshmarov
Copy link
Author

Screenshot 2024-07-24 at 19 01 40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment