Google Drive API integration with Spring Boot

Spread the love
  • 3
    Shares

We configured a project in Google Developer console and also configured OAuth credentials for a user consent. This brings us to the next step of integrating Google Drive API dependencies. The integration steps are pretty easy. Once you know the latest API versions from repositories like https://mvnrepository.com, you can easily proceed.

People putting together jigsaw puzzle pieces
Photo by rawpixel on Unsplash

Setting up Spring Boot Project

Spring has done an excellent job by building https://start.spring.io. Instead of manually creating pom.xml or build.gradle file. You have to just visit the site and specify your requirements. Interesting thing is that you don’t have to even remember group id or artifact id for spring projects as well for some of the best-known frameworks. The interface is pretty easy to use. Check below video to create your own build file.

Webjars

Instead of building a simple Spring project, we have configured another interesting dependency – webjars. Those who are not familiar with Webjars – It is a project which enables you to declare UI frameworks as a dependency in your build tools like Maven or Gradle.

You don’t have to keep separate dependency configuration for User Interface and API/Services. If you want to develop SCS (Self Contained Systems) applications webjars is an undoubtedly valuable asset.

Google Drive API dependency

Setting up Spring boot project was quite easy, now it is time to add the Google Drive Dependencies. Google has been periodically publishing the API clients for various programming languages including Java, Python, Javascript etc. Since our example uses Spring Boot, we will configure API for Java.

Once you declare the dependencies, Eclipse will take time to download the entire dependency tree. Make sure you have downloaded correct credential configuration as demonstrated in the above video.

Testing

To verify the integration steps are valid, build the entire project and then hit the URL in the browser. For the first time, you will be redirected to a Google Sign in page. Choose a suitable Google account for which you wish to access the Google Drive. The consent page can be customized as per Product requirements. Google Developer console provides rich customization options to brand the page.

Finally, you should see a success message indicating the integration is successful. At this stage we are done with all the requirements of integration. In upcoming videos we will explore various Drive APIs like Creating a file, listing files, deleting files, adding/listing comments etc.

Leave a Comment.