Created
June 23, 2022 12:57
-
-
Save mejiaro/da03fcb9d65913bbefe16c8b352ab3ca to your computer and use it in GitHub Desktop.
google oauth2 ruby client
This file contains 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
# Google can't make a decent no-frills, no shitting around for a whole day client library, | |
# 'cause probably a machine made the code/docs not a person. | |
# Fuck you Google. | |
# Get the client_id, client_secret, token, refresh token from `gcloud auth describe [email protected]` | |
# I used this to run a cloud run app thingy | |
gem install 'signet' | |
# in rails console/irb | |
require 'signet/oauth_2/client' | |
client = Signet::OAuth2::Client.new( | |
:authorization_uri => 'https://accounts.google.com/o/oauth2/auth', | |
:token_credential_uri => 'https://oauth2.googleapis.com/token', | |
:client_id => "['CLIENT_ID']", | |
:client_secret => "[CLIENT_SECRET]", | |
:scope => 'email', | |
:redirect_uri => 'postmessage' | |
) | |
client.access_token = 'last_valid_token' | |
client.refresh_token = 'refresh_token' | |
client.refresh! | |
# google oauth2 ruby | |
# ruby google_oauth2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment