Google Drive Feature Activation
K2 integrates with Google Drive through SmartObjects. To enable integration between K2 and Google Drive, activate an instance of the Google Drive feature.
- See How To: Upload a file to Google Drive with a SmartForm for an example of using the Google Drive File SmartObject to upload a file to your Google Drive.
- See How To: Use the SmartForms Tree Control to Navigate Google Drive Folders for an example of using the SmartForms Tree Control and configure it to use your Google Drive Folder SmartObject to display your Google Drive folders and files.
-
You must be a K2 administrator to activate features in K2 Management.
-
Enable your cloud storage feature activations. Follow the steps in K2 Cloud Storage.
- An active Google Drive account
Create a new Google Drive service instance by using the Google Drive feature activation. You can create multiple instances of the same feature. If you have more than one Google Drive account, you can create an instance for each one.
- Browse to the Features page in K2 Management.
- Select the Google Drive feature and click New Instance.
- Specify a name and description for your new Google Drive instance.
- Click Add.
- The configuring page shows the progress of the new instance configuration.
- During the Get OAuth Token step, you see the Google Drive login page open in a new browser tab. Specify your username and click Next.
- Specify your password and click Next.
- Click Allow to grant the Google Drive app permissions to K2. You may see a ceproxy.li permission dialog due to how Google Drive integration works. This is expected.
- Click Allow to confirm granting permissions to K2.
- Close the login page when you see the Authorization Successful message. If you do not see this page, your username and password may be incorrect.
. - Click Continue. If authorization succeeds the service instance is created. If not, the login page opens again and you can try a different Google username and password.
- Your Google Drive integration is ready to use once the Registering Service Instance step is finished.
- Click Done to close the page.
Cloud storage SmartObjects use OAuth tokens to authenticate with your cloud storage provider. Use the following authentication details to plan the behavior you need in your K2 applications:
- Workflows: When a cloud storage SmartObject method is executed without user context, such as in a SmartObject step in a workflow, the account used during Feature Activation is used to access the cloud storage provider and uses the OAuth token created during Feature Activation. See How To: Use a workflow as an intermediary to upload a file from a form to cloud storage for an example of this approach.
- SmartForms: When a cloud storage SmartObject method is executed with user context, such as in a SmartForm, the person using the form must login with their cloud storage credentials which creates an OAuth token. In this case, they have access to their own personal files and folders. See How To: Upload a file to Google Drive with a SmartForm for an example of this approach.
- If your SmartForm needs the contents of the account used during Feature Activation, every person using the form must login with that account.
- If your SmartForm needs the cloud storage contents of the person using the SmartForm, every person using the form must login with their own account.
In most cases you should use cloud storage SmartObjects methods from a workflow so that the same cloud drive is used. When using cloud storage SmartObjects with SmartForms, you can start a workflow with a button or rule to execute SmartObject methods. Only use a direct cloud storage SmartObject method in a SmartForm if you need a folder or file from the cloud storage account of the person using the SmartForm.
- Make sure you do not name files and sub-folders the same name as the parent folder. SmartObjects methods use storage paths and having files and folders with the same name may not return the correct content.
- If errors occur during the configuration, the Retry button is enabled. Leave the browser tab open and, after solving the issue, click the Retry button to continue the configuration.
- When uploading a file with the File SmartObject, you must specify the full path (including the file name and extension) in the Path property to upload the file.
- When downloading a file with the File SmartObject, you must specify the full path (including the file name and extension) in the Path property for the file you want to download.
- Using a back slash (\) in your feature name creates nested categories in the Cloud Storage folder for the instance. For example, Finance\Invoices creates Finance > Invoices and not as expected,Finance\Invoices.
- The feature activation creates three SmartObjects, File, Folder, and Service. For more information about these SmartObjects see Cloud Storage service type.
- For Upload and Copy file methods, if the destination path does not exist, it is created for you.
- You get an “Illegal characters in path” error message when you upload or download a file containing special characters in the file name or folder path name, including characters that Windows does not allow such as \/:*?"<>|.
- All methods append a leading forward slash for the value you provide in the path input property
- The List Folder Contents method supports paging, however filtering may not work as expected because filtering is performed after paging, therefore only results in the first page are filtered.
- Page size defaults to 200 entries.
- You do not need to add the trailing forward slash to paths (it is added for you when missing)
- Box and Google Drive make use of the Tags property when retrieving and updating metadata. Other storage providers either do not make use of this property or have limited support for it.
- To remove all tags from a file or folder, use the UpdateTags method and pass two empty strings "","".
- When you use the List Contents or Search SmartObject methods in SmartForms, do not select Edit all Rows or enable Add new row link since you cannot update or add new records using these methods.
- There is no Rename method or function in the SmartObjects, but you can effectively rename a file using the Move method.