-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the Simple Google Drive wiki!
The asset consists of 2 parts: Google Sign-in and use of Google Drive API. So let's start!
- Cross-platform (Android, iOS, macOS, Windows, UWP, WebGL)
- Simple and flexible code
- Easy to learn with a lot of examples
- 2-way folder synchronization implemented
- Supports both
drive
anddrive.appdata
scopes - No native plugins and 3rd party libraries
- Active support
- Simple and flexible code, easy to extend and modify
- Simple authorization witn Simple Google Sign-In
- SFSafariViewController implemented for iOS (required for passing App Store review)
- Universal Windows Platform (UWP) support and better WebGL support
- Strong C# knowledge
- LINQ basics
- Async programming basics
- Understanding Google Drive API
- Google Drive does NOT behave like your local file system! File and folder names need not be unique, even at a given level of the hierarchy. This means that a single path can describe multiple files.
- Google Drive operates with entities called
File
. This can be a file, a folder or a Google Workspace document (Google Docs, Sheets, and Slides). Each file has a MIME type. For example, folders are files with MIME typeapplication/vnd.google-apps.folder
and Google Sheets have MIME typeapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
. - Google Drive has a hierarchical structure where each file has a parent, and the root folder is
My Drive
with IDroot
(orApp Folder
with IDappDataFolder
). - Google Drive API doesn't support paths as we used to work with in Android or Windows, so we have to implement path resolving by iterating through parents and childs (if we want to operate with paths, of course).
- Google Drive file names are case sensitive, unlike File System names for most platforms.
You need to purchase and import Simple Google Sign-In and follow setup steps described in Wiki. IMPORTANT! Add Google Drive API access scope on Google Cloud > APIs & Services > OAuth consent screen
. After obtaining a valid access token you can start using Google Drive API.
-
https://www.googleapis.com/auth/drive.appdata
(preferred) allows to work with the app folder only. This is a non-sensitive scope and your app doesn't require to be validated by Google. The application data folder is a special hidden folder that your app can use to store application-specific data, such as configuration files. The application data folder is automatically created when you attempt to create a file in it. Use this folder to store any files that the user shouldn't directly interact with. This folder is only accessible by your application and its contents are hidden from the user and from other Drive apps. The root isApp Folder
with IDappDataFolder
. With this scope, you can't work withTrash
or other locations except the app folder. More info: Store application-specific data. -
https://www.googleapis.com/auth/drive
allows to see, edit, create, and delete all Google Drive files avaialble for the current user. This is a restricted scope, so your app should be validated by Google (Google Cloud > APIs & Services > OAuth consent screen
). The root folder isMy Drive
with IDroot
.
- You've imported BOTH assets: Simple Google Sign-In and Simple Google Drive.
- You've created Google credentials with Google Drive API scope.
- You've changed credentials in
SimpleGoogleDrive/Resources/GoogleAuthSettings
. - You can sign in with Google and obtain an access token (press
Sign in
in theExamples
scene). You may see the warningThis app isn't verified
when signing in to Google, it's because your app uses a restricted scope and wasn't reviewed by Google. It's ok, just pressAdvanced
to continue.
Your entry point is GoogleDrive
class. It contains core functions to work with Google Drive API. GoogleDriveExtensions
provides extra methods that can't be related to core functions. The asset includes examples for all basic actions, just refer to Examples
scene and scripts inside the Examples
folder.
- Write a review on the Asset Store =)
- Remove debug logs with sensitive data (like access tokens), set
GoogleDrive.DebugLog = false
- Add new functions by extending
GoogleDrive
andGoogleDriveExtensions
(or contact me for updating/extending the asset) - Send your app for review if you use the restricted scope
https://www.googleapis.com/auth/drive
. It's not so easy as you may think, so be patient.
I'm a developer of Pixel Studio, a cross-platform drawing app. I use Google Drive to allow users to sync their files across different platforms. I was using Unity Google Drive before, a free asset made by Artyom Sovetnikov (Elring). Finally, I decided to make my own asset, with blackjack and hookers, of course. And stop using Unity Google Drive. There are a lot of reasons:
- The project is abandoned, the developer doesn't fix issues (they are auto closed by the bot)
- Very complicated and confusing code, high entry threshold
- Complicated authorization setup
- Native plugins and 3rd party libraries
- Strict mapping to Google Drive API, it's hard to modify or extend the code
- No support for Universal Windows Platform (UWP) due to outdated authorization method
- WebGL apps need to be restarted when performing Google auth