gimite / google-drive-ruby

A Ruby library to read/write files/spreadsheets in Google Drive/Docs.
Other
1.76k stars 493 forks source link

Deprecated OAuth out-of-band (oob) flow #420

Open fadeltd opened 2 years ago

fadeltd commented 2 years ago

OAuth out-of-band (oob) flow will be deprecated

https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html

https://github.com/gimite/google-drive-ruby/blob/55b996b2c287cb0932824bf2474248a498469328/lib/google_drive/session.rb#L158

New OAuth usage will be blocked for the OOB flow

image

Can we migrate to an alternative flow? https://developers.google.com/identity/protocols/oauth2/native-app#redirect-uri_loopback

septianmalela commented 2 years ago

Hi, i think the error redirect url not valid, i have same issue with you and i solved the issue.

maybe the step link this

  1. you create new routes for get callback response from google, maybe like this get 'google_drive_response', to: 'public_page#google_drive_response'
  2. you register url on google console image
  3. change redirect url change to routes callback response, for example like this redirect_uri: "http://localhost:3000/google_drive_response/"

i hope you issue is solved, because me solved the issue:))

koos commented 1 year ago

Also waiting for a proper solution on this. @gimite ?

koos commented 1 year ago

Wouldn't it be a solution to replace:

https://github.com/gimite/google-drive-ruby/blob/55b996b2c287cb0932824bf2474248a498469328/lib/google_drive/session.rb#L158C1-L159C1

with

redirect_uri: config.redirect_uri

and just pass a 'dummy' redirect_uri in your method? Something like this:

require 'google_drive'


require 'google_drive'

class GoogleDriveService

  attr_accessor :client_id, :client_secret, :redirect_uri, :refesh_token, :scope, :save, :scope, :refresh_token

  def initialize(client_id, client_secret, redirect_uri)
    @client_id = client_id
    @client_secret = client_secret
    @redirect_uri = redirect_uri
  end

  def create_session
    session = GoogleDrive::Session.from_config(self)
  end

end```