Last active
August 29, 2015 14:14
-
-
Save cigalecigales/c918fbac1080b038f787 to your computer and use it in GitHub Desktop.
[*Ruby*] RubyでGoogle Drive APIを使ってファイル一覧取得&ファイルアップロード ref: http://qiita.com/cigalecigales/items/470e81c78cf3ef350b0c
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
[クライアントID] | |
127036428910-2cihomq21p413jtu4ebmf4kvefi8v9p1.apps.googleusercontent.com | |
[クライアントシークレット] | |
2KR6kOI2hOs0QSKqqltrkyfi | |
[リダイレクトURI] | |
http://localhost |
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
https://accounts.google.com/o/oauth2/auth | |
?client_id=クライアントID | |
&redirect_uri=リダイレクトURI | |
&scope=https://www.googleapis.com/auth/drive | |
&response_type=code |
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
curl -d client_id=127036428910-2cihomq21p413jtu4ebmf4kvefi8v9p1.apps.googleusercontent.com -d client_secret=2KR6kOI2hOs0QSKqqltrkyfi -d refresh_token=1/djoROZFMLKPHygvCqtREUAnF7ddeG-3mtXagaXwXAUg -d grant_type=refresh_token https://accounts.google.com/o/oauth2/token |
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
{ | |
"access_token" : "ya29.DwHCrzGUsuzSUnFUKCHUugHXh3lTbYuBkn0fHk4lA33zxdGiFxT8palk5rvmR4PYlGqhlfFsRWzTBA", | |
"token_type" : "Bearer", | |
"expires_in" : 3600 | |
} |
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
$ gem install google_drive |
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
$ ruby google-api-get-list.rb | |
IMG_0456.JPG | |
IMG_0454.JPG | |
IMG_0455.JPG | |
IMG_0451.JPG | |
(省略) |
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
https://accounts.google.com/o/oauth2/auth | |
?client_id=127036428910-2cihomq21p413jtu4ebmf4kvefi8v9p1.apps.googleusercontent.com | |
&redirect_uri=http://localhost | |
&scope=https://www.googleapis.com/auth/drive | |
&response_type=code |
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
http://localhost/?code=4/oIZC2ivBC4zV5subNiN6bou8uowe0Ix9L9TB5jDKUKs.IgN5uoclywkaBrG_bnfDxpI4cUOelgI |
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
curl -d client_id=[クライアントID] -d client_secret=[クライアントシークレット] -d redirect_uri=[リダイレクトURI] -d grant_type=authorization_code -d code=[Authorization Code] https://accounts.google.com/o/oauth2/token |
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
curl -d client_id=127036428910-2cihomq21p413jtu4ebmf4kvefi8v9p1.apps.googleusercontent.com -d client_secret=2KR6kOI2hOs0QSKqqltrkyfi -d redirect_uri=http://localhost -d grant_type=authorization_code -d code=4/oIZC2ivBC4zV5subNiN6bou8uowe0Ix9L9TB5jDKUKs.IgN5uoclywkaBrG_bnfDxpI4cUOelgI https://accounts.google.com/o/oauth2/token |
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
{ | |
"access_token" : "ya29.DwGisAjZTMSJH6biEjydYXIp6JaXRmYnh21CrW09XpSZzbyRtlg9xmONE1TD7tDDawQgpTjHgZD0kA", | |
"token_type" : "Bearer", | |
"expires_in" : 3600, | |
"refresh_token" : "1/djoROZFMLKPHygvCqtREUAnF7ddeG-3mtXagaXwXAUg" | |
} |
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
{ | |
"error" : "invalid_grant" | |
} |
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
{ | |
"error" : "invalid_grant", | |
"error_description" : "Code was already redeemed." | |
} |
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
curl -d client_id=[クライアントID] -d client_secret=[クライアントシークレット] -d refresh_token=[リフレッシュトークン] -d grant_type=refresh_token https://accounts.google.com/o/oauth2/token |
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
file_name = "Test" + Time.now.strftime('%Y-%m-%d_%H:%M:%S') + ".txt" | |
file = File.open(file_name, 'w') | |
file.puts("Test Upload!!") | |
file.close | |
session.upload_from_file(file_name, file_name, :convert => false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment