{"id":627,"date":"2015-09-06T23:39:21","date_gmt":"2015-09-06T18:39:21","guid":{"rendered":"http:\/\/128.199.176.160\/?p=627"},"modified":"2026-05-13T11:53:12","modified_gmt":"2026-05-13T06:53:12","slug":"diving-in-google-drive-apis-list-files-and-folders","status":"publish","type":"post","link":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/","title":{"rendered":"Diving in Google Drive APIs \u2013 List Files and Folders"},"content":{"rendered":"\n<p>Today, we are going to actually start playing with Google Drive APIs. Previous parts served as the basis for implementing web apps using Google APIs. In part 3, we will use Google Drive&#8217;s file listing functions to list files and folders and display them on a page.<\/p>\n\n\n\n<p>I assume you have already gone through the authentication and Installation process.\u00a0I have shared my code on <a href=\"https:\/\/github.com\/hiddenpearls\/Google-PHP-Samples\" type=\"link\" id=\"https:\/\/github.com\/hiddenpearls\/Google-PHP-Samples\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">GitHub<\/a>, where we are moving toward building a simple web app to list our Google Drive files and perform operations, etc.<\/p>\n\n\n\n<p>The following is a simple function that fetches the latest 100 files from the user&#8217;s Google account and displays them on the page. We are displaying their file titles and their icons, which represent their file types. For example, it can be a spreadsheet, an image, or a folder.<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/hiddenpearls\/e8c0e53d93a9db9bd3f5.js\"><\/script><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-consolusion\">Consolusion<\/h3>\n\n\n\n<p>If you look at my complete web app files, you will see I have managed Authentication and other aspects in a way that makes them <em><strong>VERY<\/strong><\/em> easy to understand and follow. In any case, you don&#8217;t understand or have a better idea to achieve the same thing I did, shout below in comments \ud83d\ude09<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, we are going to actually start playing with Google Drive APIs. Previous parts served as the basis for implementing web apps using Google APIs. In part 3, we will use Google Drive&rsquo;s file listing functions to list files and folders and display them on a page. I assume you have already gone through the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":320828,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_analytify_skip_tracking":false,"footnotes":""},"categories":[85,53],"tags":[99,103],"class_list":["post-627","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-drive","category-how-to","tag-google-drive","tag-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Diving in Google Drive APIs \u2013 List Files and Folders - WPBrigade<\/title>\n<meta name=\"description\" content=\"We are going to actually start playing with Google Drive APIs. Previous parts were base for\u00a0implementation of web apps with Google APIs.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Diving in Google Drive APIs \u2013 List Files and Folders\" \/>\n<meta property=\"og:description\" content=\"We are going to actually start playing with Google Drive APIs. Previous parts were base for\u00a0implementation of web apps with Google APIs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/\" \/>\n<meta property=\"og:site_name\" content=\"WPBrigade\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/WPBrigade\" \/>\n<meta property=\"article:published_time\" content=\"2015-09-06T18:39:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-13T06:53:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wpbrigade.com\/wp-content\/uploads\/2015\/09\/diving-in-google-drive-apis-list-files-and-folders1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1500\" \/>\n\t<meta property=\"og:image:height\" content=\"800\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Adnan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@wpbrigade\" \/>\n<meta name=\"twitter:site\" content=\"@wpbrigade\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Adnan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/\"},\"author\":{\"name\":\"Adnan\",\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/#\\\/schema\\\/person\\\/60305aa637f786ceebbf9949f1a24634\"},\"headline\":\"Diving in Google Drive APIs \u2013 List Files and Folders\",\"datePublished\":\"2015-09-06T18:39:21+00:00\",\"dateModified\":\"2026-05-13T06:53:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/\"},\"wordCount\":199,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wpbrigade.com\\\/wp-content\\\/uploads\\\/2015\\\/09\\\/diving-in-google-drive-apis-list-files-and-folders1.png\",\"keywords\":[\"Google Drive\",\"PHP\"],\"articleSection\":[\"Google Drive\",\"How-to\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/\",\"url\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/\",\"name\":\"Diving in Google Drive APIs \u2013 List Files and Folders - WPBrigade\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wpbrigade.com\\\/wp-content\\\/uploads\\\/2015\\\/09\\\/diving-in-google-drive-apis-list-files-and-folders1.png\",\"datePublished\":\"2015-09-06T18:39:21+00:00\",\"dateModified\":\"2026-05-13T06:53:12+00:00\",\"description\":\"We are going to actually start playing with Google Drive APIs. Previous parts were base for\u00a0implementation of web apps with Google APIs.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/#primaryimage\",\"url\":\"https:\\\/\\\/wpbrigade.com\\\/wp-content\\\/uploads\\\/2015\\\/09\\\/diving-in-google-drive-apis-list-files-and-folders1.png\",\"contentUrl\":\"https:\\\/\\\/wpbrigade.com\\\/wp-content\\\/uploads\\\/2015\\\/09\\\/diving-in-google-drive-apis-list-files-and-folders1.png\",\"width\":1500,\"height\":800,\"caption\":\"Diving in google drive apis list and folders\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/diving-in-google-drive-apis-list-files-and-folders\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wpbrigade.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Diving in Google Drive APIs \u2013 List Files and Folders\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/#website\",\"url\":\"https:\\\/\\\/wpbrigade.com\\\/\",\"name\":\"WPBrigade\",\"description\":\"WordPress Development Agency\",\"publisher\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wpbrigade.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/#organization\",\"name\":\"WPBrigade\",\"url\":\"https:\\\/\\\/wpbrigade.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wpbrigade.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/Screen-Shot-2021-07-02-at-12.42.14-AM.png\",\"contentUrl\":\"https:\\\/\\\/wpbrigade.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/Screen-Shot-2021-07-02-at-12.42.14-AM.png\",\"width\":271,\"height\":63,\"caption\":\"WPBrigade\"},\"image\":{\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/facebook.com\\\/WPBrigade\",\"https:\\\/\\\/x.com\\\/wpbrigade\",\"https:\\\/\\\/www.instagram.com\\\/wpbrigade.agency\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/wpbrigade\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/Wpbrigade\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/wpbrigade.com\\\/#\\\/schema\\\/person\\\/60305aa637f786ceebbf9949f1a24634\",\"name\":\"Adnan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/db5b529a3f883d64715e1ccef9fbb1b5d602be4f9430721c997513571f1ce99f?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/db5b529a3f883d64715e1ccef9fbb1b5d602be4f9430721c997513571f1ce99f?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/db5b529a3f883d64715e1ccef9fbb1b5d602be4f9430721c997513571f1ce99f?s=96&d=retro&r=g\",\"caption\":\"Adnan\"},\"sameAs\":[\"http:\\\/\\\/adnan.pk\\\/\",\"https:\\\/\\\/x.com\\\/wpbrigade\"]}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Diving in Google Drive APIs \u2013 List Files and Folders - WPBrigade","description":"We are going to actually start playing with Google Drive APIs. Previous parts were base for\u00a0implementation of web apps with Google APIs.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/","og_locale":"en_US","og_type":"article","og_title":"Diving in Google Drive APIs \u2013 List Files and Folders","og_description":"We are going to actually start playing with Google Drive APIs. Previous parts were base for\u00a0implementation of web apps with Google APIs.","og_url":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/","og_site_name":"WPBrigade","article_publisher":"https:\/\/facebook.com\/WPBrigade","article_published_time":"2015-09-06T18:39:21+00:00","article_modified_time":"2026-05-13T06:53:12+00:00","og_image":[{"width":1500,"height":800,"url":"https:\/\/wpbrigade.com\/wp-content\/uploads\/2015\/09\/diving-in-google-drive-apis-list-files-and-folders1.png","type":"image\/png"}],"author":"Adnan","twitter_card":"summary_large_image","twitter_creator":"@wpbrigade","twitter_site":"@wpbrigade","twitter_misc":{"Written by":"Adnan","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/#article","isPartOf":{"@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/"},"author":{"name":"Adnan","@id":"https:\/\/wpbrigade.com\/#\/schema\/person\/60305aa637f786ceebbf9949f1a24634"},"headline":"Diving in Google Drive APIs \u2013 List Files and Folders","datePublished":"2015-09-06T18:39:21+00:00","dateModified":"2026-05-13T06:53:12+00:00","mainEntityOfPage":{"@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/"},"wordCount":199,"commentCount":1,"publisher":{"@id":"https:\/\/wpbrigade.com\/#organization"},"image":{"@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/#primaryimage"},"thumbnailUrl":"https:\/\/wpbrigade.com\/wp-content\/uploads\/2015\/09\/diving-in-google-drive-apis-list-files-and-folders1.png","keywords":["Google Drive","PHP"],"articleSection":["Google Drive","How-to"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/","url":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/","name":"Diving in Google Drive APIs \u2013 List Files and Folders - WPBrigade","isPartOf":{"@id":"https:\/\/wpbrigade.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/#primaryimage"},"image":{"@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/#primaryimage"},"thumbnailUrl":"https:\/\/wpbrigade.com\/wp-content\/uploads\/2015\/09\/diving-in-google-drive-apis-list-files-and-folders1.png","datePublished":"2015-09-06T18:39:21+00:00","dateModified":"2026-05-13T06:53:12+00:00","description":"We are going to actually start playing with Google Drive APIs. Previous parts were base for\u00a0implementation of web apps with Google APIs.","breadcrumb":{"@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/#primaryimage","url":"https:\/\/wpbrigade.com\/wp-content\/uploads\/2015\/09\/diving-in-google-drive-apis-list-files-and-folders1.png","contentUrl":"https:\/\/wpbrigade.com\/wp-content\/uploads\/2015\/09\/diving-in-google-drive-apis-list-files-and-folders1.png","width":1500,"height":800,"caption":"Diving in google drive apis list and folders"},{"@type":"BreadcrumbList","@id":"https:\/\/wpbrigade.com\/diving-in-google-drive-apis-list-files-and-folders\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wpbrigade.com\/"},{"@type":"ListItem","position":2,"name":"Diving in Google Drive APIs \u2013 List Files and Folders"}]},{"@type":"WebSite","@id":"https:\/\/wpbrigade.com\/#website","url":"https:\/\/wpbrigade.com\/","name":"WPBrigade","description":"WordPress Development Agency","publisher":{"@id":"https:\/\/wpbrigade.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wpbrigade.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wpbrigade.com\/#organization","name":"WPBrigade","url":"https:\/\/wpbrigade.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpbrigade.com\/#\/schema\/logo\/image\/","url":"https:\/\/wpbrigade.com\/wp-content\/uploads\/2021\/07\/Screen-Shot-2021-07-02-at-12.42.14-AM.png","contentUrl":"https:\/\/wpbrigade.com\/wp-content\/uploads\/2021\/07\/Screen-Shot-2021-07-02-at-12.42.14-AM.png","width":271,"height":63,"caption":"WPBrigade"},"image":{"@id":"https:\/\/wpbrigade.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/WPBrigade","https:\/\/x.com\/wpbrigade","https:\/\/www.instagram.com\/wpbrigade.agency\/","https:\/\/www.linkedin.com\/company\/wpbrigade","https:\/\/www.youtube.com\/c\/Wpbrigade"]},{"@type":"Person","@id":"https:\/\/wpbrigade.com\/#\/schema\/person\/60305aa637f786ceebbf9949f1a24634","name":"Adnan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/db5b529a3f883d64715e1ccef9fbb1b5d602be4f9430721c997513571f1ce99f?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/db5b529a3f883d64715e1ccef9fbb1b5d602be4f9430721c997513571f1ce99f?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/db5b529a3f883d64715e1ccef9fbb1b5d602be4f9430721c997513571f1ce99f?s=96&d=retro&r=g","caption":"Adnan"},"sameAs":["http:\/\/adnan.pk\/","https:\/\/x.com\/wpbrigade"]}]}},"_links":{"self":[{"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/posts\/627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/comments?post=627"}],"version-history":[{"count":2,"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/posts\/627\/revisions"}],"predecessor-version":[{"id":320829,"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/posts\/627\/revisions\/320829"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/media\/320828"}],"wp:attachment":[{"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/media?parent=627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/categories?post=627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpbrigade.com\/wpb-api\/wp\/v2\/tags?post=627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}