Created
November 21, 2013 14:21
-
-
Save ThomasLocke/7582314 to your computer and use it in GitHub Desktop.
How to access Google Drive from Dart.
This file contains hidden or 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
| // Add google_drive_v2_api to pubspec.yaml | |
| import "package:google_oauth2_client/google_oauth2_console.dart" as oauth; | |
| import "package:google_drive_v2_api/drive_v2_api_console.dart" as drivelib; | |
| const _IDENTIFIER = "<YOUR CLIENT ID>"; | |
| const _SECRET = "<YOUR CLIENT SECRET>"; | |
| const _SCOPES = const ["https://www.googleapis.com/auth/drive.file"]; | |
| void main() { | |
| oauth.OAuth2Console auth = new oauth.OAuth2Console(identifier: _IDENTIFIER, | |
| secret: _SECRET, | |
| scopes: _SCOPES); | |
| drivelib.Drive drive = new drivelib.Drive(auth); | |
| String fileid = "<SOME FILE ID>"; | |
| drive.makeAuthRequests = true; | |
| drive.files.get(fileid).then((data) => print(data.toString())); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment