Class: GoogleDrive::OAuth
- Inherits:
-
Object
- Object
- GoogleDrive::OAuth
- Defined in:
- lib/google_drive_oauth.rb
Constant Summary collapse
- REDIRECT_URL =
"urn:ietf:wg:oauth:2.0:oob"
Instance Method Summary collapse
- #auth_url ⇒ Object
- #drive_session(access_token: nil, refresh_token: options[:refresh_token]) ⇒ Object
- #get_token(authorization_code) ⇒ Object
-
#initialize(options) ⇒ OAuth
constructor
A new instance of OAuth.
Constructor Details
#initialize(options) ⇒ OAuth
Returns a new instance of OAuth.
8 9 10 |
# File 'lib/google_drive_oauth.rb', line 8 def initialize() @options = end |
Instance Method Details
#auth_url ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/google_drive_oauth.rb', line 12 def auth_url client.auth_code.( :redirect_uri => REDIRECT_URL, :scope => "https://www.googleapis.com/auth/drive " + "https://spreadsheets.google.com/feeds/" ) end |
#drive_session(access_token: nil, refresh_token: options[:refresh_token]) ⇒ Object
26 27 28 29 30 |
# File 'lib/google_drive_oauth.rb', line 26 def drive_session(access_token: nil, refresh_token: [:refresh_token]) access_token = load_token(refresh_token) if access_token.nil? access_token = access_token.refresh! if access_token.token.empty? or access_token.expired? GoogleDrive.login_with_oauth(access_token.token) end |
#get_token(authorization_code) ⇒ Object
20 21 22 23 24 |
# File 'lib/google_drive_oauth.rb', line 20 def get_token() client.auth_code.get_token( , :redirect_uri => REDIRECT_URL) end |