Last active
June 18, 2018 12:03
-
-
Save amitpatelx/b11ce603f53d4c49f49ee7dd31a4739d to your computer and use it in GitHub Desktop.
Generate Google API token using refresh token
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
require "googleauth" | |
redentials = | |
Google::Auth::UserRefreshCredentials.new( | |
client_id: "3453463453ghjejfrekjfrekgjher.apps.googleusercontent.com", | |
client_secret: "dnbddfjfjkffrfrfj", | |
scope: ["https://www.googleapis.com/auth/drive"], # enter the scope for a service whichever you want to use | |
additional_parameters: { "access_type" => "offline" }) # DO not forgot to add this | |
# Set the refresh token | |
credentials.refresh_token = '1/clpHfRpyVonjRpYFyfstY3zD9TSX6MgcX2C1lJ-RTEQ' | |
# Generate new access token | |
credentials.fetch_access_token! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment