# ASP.NET MVC + Google Drive API



## beingGamer (May 27, 2014)

Hi all,
I need urgent help with Google Drive integration into a ASP.net MVC web application hosted on a server.
The requirement is as follows-

1. the web application has users, using drive api, the files present inside each user's drive should be retrieved. for user specific google drive i am storing each user's google id in database.

2. when user uploads a file, that file should be uploaded to his own google drive, Delete & Update operations on the listed files.


1. I managed to do all the above operations on localhost. but when i published to the server, it gets stuck at this line -

```
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                new ClientSecrets
                {
                    ClientId = ClientId,
                    ClientSecret = ClientSecret,
                },
                new[] { DriveService.Scope.Drive },
                "user",
                CancellationToken.None).Result;
```

2. I also think that, the way I implemented the upload file functionality is not correct.
current approach-


> 1. Upload a file from the domain admin account (using client id & client secret)
> 2. add 'Owner' permission to the required user for the uploaded file.​



I saw one of the examples, according to that-


> we have to impersonate the required user while uploading the file





I have wasted around 1 week on doing this, and still not able to make it work on the server.

Please guide me with this if you have worked on oAuth2 & Google API or anything similar to this scenario.


----------



## beingGamer (Jul 9, 2014)

Researched very deeply & got a help from friend who suggested Postman plugin for chrome to achieve what i was trying to do.

To use google drive's functions there are request URIs to which we have to send our parameters. The response comes in JSON format.
so using the JSON formatted data we can do lot of things like - Get list of files in google drive(or a perticular folder), upload files, download files, edit, delete files. get details such as file type, size, who uploaded the file, upload date and almost everything related to the file 

Admins can close the thread


----------

