Repository is archived
No commit activity in last 3 years
No release in over 3 years
bridge for supporting multiple google authentication libraries
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Google Authentication Bridge

Google allow you to authenticate with their APIs with OAuth. That process can be a little tedious if you have to do it over and over. Google Authentication Bridge allows you to authenticate with Google and will store the refresh token in a file for subsequent use.

Usage

With Google Drive https://github.com/gimite/google-drive-ruby

auth = GoogleAuthenticationBridge::GoogleAuthentication.new(
  "https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/",
  "client-id",
  "client-secret",
  "/path/to/token-file.yml"
)
# first time to create the refresh token
token = auth.get_oauth2_access_token("auth-code")
# subsequent times using the refresh token
token = auth.get_oauth2_access_token
session = GoogleDrive.login_with_oauth(token)

With Google API Client http://code.google.com/p/google-api-ruby-client/

auth = GoogleAuthenticationBridge::GoogleAuthentication.new(
  "https://www.googleapis.com/auth/analytics.readonly",
  "client-id",
  "client-secret",
  "/path/to/token-file.yml"
)
# first time to create the refresh token
token = auth.get_tokens("auth-code")
# subsequent times using the refresh token
token = auth.get_tokens

client = Google::APIClient.new
client.update_token!(token)

Rather than providing the credentials directly you can build the authentication object from a YAML configuration file.

auth = GoogleAuthenticationBridge::GoogleAuthentication.create_from_config_file(
  "scope",
  "/path/to/credentials.yml",
  "/path/to/token-file.yml"
)

The credentials file should contain the client id and the client secret.

---
:google_client_id: "client id"
:google_client_secret: "client secret"