Created
October 29, 2014 11:20
-
-
Save khacanh/c33574c718b8499adec8 to your computer and use it in GitHub Desktop.
google-client-ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@json_schema="method:STRING,path:STRING,format:STRING,controller:STRING,action:STRING,status:INTEGER,duration:FLOAT,time:TIMESTAMP,view:FLOAT,db:FLOAT,user_agent:STRING,authorization:STRING,error:STRING" | |
{ | |
"configuration" => { | |
"load" => { | |
"sourceFormat" => "NEWLINE_DELIMITED_JSON", | |
"schema" => @json_schema, | |
"destinationTable" => { | |
"projectId" => @project_id, | |
"datasetId" => @dataset, | |
"tableId" => @table_id | |
}, | |
'createDisposition' => 'CREATE_IF_NEEDED', | |
'writeDisposition' => 'WRITE_APPEND' | |
} | |
} | |
} | |
require 'google/api_client/client_secrets' | |
require 'google/api_client/auth/installed_app' | |
client = Google::APIClient.new( | |
:application_name => 'RAILS LOG', | |
:application_version => '1.0.0' | |
) | |
client_secrets = Google::APIClient::ClientSecrets.load | |
flow = Google::APIClient::InstalledAppFlow.new( | |
:client_id => client_secrets.client_id, | |
:client_secret => client_secrets.client_secret, | |
:scope => ['https://www.googleapis.com/auth/bigquery'] | |
) | |
client.authorization = flow.authorize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment