Skip to content

Instantly share code, notes, and snippets.

@ThomasLocke
Created November 21, 2013 14:21
Show Gist options
  • Save ThomasLocke/7582314 to your computer and use it in GitHub Desktop.
Save ThomasLocke/7582314 to your computer and use it in GitHub Desktop.
How to access Google Drive from Dart.
// 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