Skip to content

Installed app sample #446

@LindaLawton

Description

@LindaLawton

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    samplesIssues that are directly related to samples.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions