Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installed app sample #446

Open
LindaLawton opened this issue Aug 28, 2023 · 0 comments
Open

Installed app sample #446

LindaLawton opened this issue Aug 28, 2023 · 0 comments
Labels
samples Issues that are directly related to samples.

Comments

@LindaLawton
Copy link

LindaLawton commented Aug 28, 2023

Can someone tell me why Example (Command Line) [Deprecated] is deprecated.

Yes oob has stopped working but all of the other client libraries, .net, php, python, golang, java have just switched to using http:\localhost as the migration guide recommends oob-migration

Any special reason why that wont work in this library and with the existing sample?

works fine

require 'googleauth'
require "googleauth/stores/file_token_store"
require 'google/apis/drive_v3'

#  gem install google_auth
#  gem install google_drive

OOB_URI = 'http://localhost'
CREDENTIALS_FILE_PATH = 'C:\Development\FreeLance\GoogleSamples\Credentials\credentials.json'

scope = 'https://www.googleapis.com/auth/drive'
client_id = Google::Auth::ClientId.from_file(CREDENTIALS_FILE_PATH)
token_store = Google::Auth::Stores::FileTokenStore.new(:file => 'C:\Users\linda\RubymineProjects\tokens.yaml')
authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)

user_id = ENV['USER']
credentials = authorizer.get_credentials(user_id)
if credentials.nil?
  url = authorizer.get_authorization_url(base_url: OOB_URI )
  puts "Open #{url} in your browser and enter the resulting code:"
  code = gets
  credentials = authorizer.get_and_store_credentials_from_code(
    user_id: user_id, code: code, base_url: OOB_URI)
end

drive = Google::Apis::DriveV3::DriveService.new
drive.authorization = credentials

# Search for files in Drive (first page only)
files = drive.list_files()
files.items.each do |file|
  puts file.title
end
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

No branches or pull requests

1 participant