Created
July 24, 2024 17:01
-
-
Save yshmarov/8858d6a05c94db61fa0de2caa44f688a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Author
yshmarov
commented
Jul 24, 2024

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