In this article, we’ll show you how to retrieve a list of files from Google Drive via REST API and display those files in your PHPRunner or ASPRunner.NET application. This is how it looks in the generated application. The list of files is retrieved from Google Drive and displayed in your own application. In this test app, we only implemented search and view functionality, but adding and deleting files can be done as well.
1. Create API credentials in Google Cloud console
Proceed to Google Cloud console. Under APIs & Services -> Credentials click ‘+ Create Credentials’. Choose ‘OAuth client ID’ option. On the next screen choose ‘Web application’ as Application Type.
Once OAuth client is created copy ClientID and Client Secret, you are going to need them to create a REST API connection in PHPRunner or ASPRunner.NET.
In Oauth Client properties add Authorized redirect URIs. For local testing use:
PHPRunner
ASPRunner.NET
For production use:
PHPRunner
ASPRunner.NET
2. Enable Google Drive API
Under ‘Library’ find ‘Google Drive API’, click it and then click ‘Enable’.
2. Create REST API connection
Proceed to PHPRunner or ASPRunner.NET and add a new REST API connection to your project. Choose ‘OAuth 2.0 – User’ as the authorization method.
Paste your saved Client ID and Client Secret there. The rest of the settings should be as specified below.
Authorization URI
Access token URI
Scope
More info: Google Drive API reference
3. Enable List operation
This is what you need to add to the Resource box:
4. Adding a list of fields
Since this API uses OAuth – User type of authentication we cannot run the request in the software and have to specify a list of fields manually. We have pulled the list of available fields from the Google Driver REST API docs. This is how a single field setup looks:
For simplicity purposes, we use ‘string’ type for all fields. Here is the list of all available fields: name, id, description, trashed, starred, mimeType, hasThumbnail, thumbnailLink, modifiedTime, createdTime, webContentLink, webViewLink.
5. Enable Single operation
This is what you need to add to the Resource box:
This is pretty much it. Once you build and run your application you will be presented with a Google Account login window. You can logon or choose one from your Google Accounts once once you are in you will see a list of files stored on your Google Drive.
nice how about dropbox have you got a similar example ? thanks