Friday, October 5, 2018

Implemting Google Drive File Uploader using OAuth

Implementing Google Drive Text File Uploader using OAuth 2.0


Creating Project and Registering your API with Google


In this part we will register our project with google to get the credentials file required to implement the application.
Navigate to https://console.developers.google.com/flows/enableapi?apiid=drive&pli=1 to start registering your api.

1. Create a project and continue



2. Enable API and go to credentials







3. Proceed to get your credentials (Click cancel in this window)
4. Navigate OAuth Consent Screen and fill the name and email using and save

 

5. Navigate to credentials tab and select OAuth client id
  
 6. Create OAuth client id (Select other)


7. After saving download your credentials.




 

Configuring Apache Tomcat Server 7 in NetBeans IDE 

1. Navigate to https://tomcat.apache.org/download-70.cgi and download Core: 64-bit Windows zip and extract it to a location.

2. Go to tools -> server in NetBeans and click on Add Server





3. Set Server location to your extracted file path and create a user.


 

Now you can test server by running it. You should see Apache Tomcat webpage loaded locally.

Building the Project using NetBeans 

1. Main User Interface where user browse and click on upload.

2. Loading credentials into the program.
    Rename your credentials json file to client_secret.json and place it inside the user home directory/credentials/ folder for windows.
eg C:/Users/{UserName}/credentials/client_secret.json

 

3. Create Google file from java.io file.


4. Upload success response and generating the link to view.
 

5. Final Response User Interface,


6. Built the project.





Running the Project using NetBeans 

Clone the project from github into a directory and open it using netbeans.

https://github.com/vimukthimudalige/OAuth_Google_Drive_File_Uploader.git

1. Add the required dependencies as shown if any is missing.



2. Run Upload using Apache Tomcat Server 7.

 

3. For the first time you will be asked to allow the app from google. Pick your account and allow it.






4. You should see following window and browse a text file and click on upload.
  

5. You should get a upload success webpage.
 

6. If you browse into output logs you should see the url to view the uploaded file.


 

7. File will be uploaded to your google drive.



Implemting Google Drive File Uploader using OAuth

Implementing Google Drive Text File Uploader using OAuth 2.0 Creating Project and Registering your API with Google In this part we wil...