16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/aws_auditor/google.rb', line 16
def self.get_authorization
creds = load_config[:credentials]
client = ::Google::APIClient.new
auth = client.authorization
auth.client_id = creds[:client_id]
auth.client_secret = creds[:client_secret]
auth.scope =
"https://www.googleapis.com/auth/drive " +
"https://docs.google.com/feeds/ " +
"https://docs.googleusercontent.com/ " +
"https://spreadsheets.google.com/feeds/"
auth.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
print("1. If it doesn't automatically open, open this page:\n%s\n\n" % auth.authorization_uri)
`open "#{auth.authorization_uri}"`
print("2. Enter the authorization code shown in the page: ")
auth.code = $stdin.gets.chomp
auth.fetch_access_token!
access_token = auth.access_token
end
|