kelvinRosa / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

Accessing Google Drive API from Windows Service & Obtaining Refresh Token from .Net Library #430

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Google Drive API - Latest - with OAuth2

Good afternoon,

I have 2 issues that I'm having difficulty with.  The first is with an asp.net 
MVC4 app.

-I've successfully implemented the MVC helper classes provided in the 
Google.Apis.Auth.OAuth2.Mvc namespace (AuthCallbackController & 
AppFlowMetadata) and am authenticating well.  Issue here is that once I am in 
my AuthCallbackController/IndexAsync method, I successfully exchange the code 
for a token by using Flow.ExchangeCodeForTokenAsync(...) and get a token.  
However, this token doesn't yet have a refresh token, just an access token and 
an expires in value.  What is the way with the .Net libs to request a refresh 
token?  I know how to do it via WebRequest and query params, but I want to 
stick with the provided libs.

-Second issue: I'm needing to build a Windows Service to pull down specific 
data from a specific directory that my secure user will have access to.  I 
cannot use OAuth for this, as it's a windows service, but I really need the 
querying functionality provided by the Drive api, as it appears more robust 
that the older GData.Spreadsheets libs utilities.  I'm having to look at folder 
structures, naming conventions of nested folders, etc... to parse data and put 
back into a db.  Any documentation or sample you could provide simply on how I 
get to a hydrated DriveService object from this route?  Once I have a 
DriveService that is authenticated, I'd just use it per the API to query for 
modified files, etc...

I apologize if this is a ton to ask and/or if there's already an answer out 
there that I've missed.  

Thank you for your time!!  Any direction provided will be greatly appreciated!

-Cites:
OAuth2 & MVC Libs: 
https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2#Web_Applications_
(using_ASP.NET_MVC) 

-Bradley

Original issue reported on code.google.com by bradley...@gmail.com on 13 Dec 2013 at 10:27

GoogleCodeExporter commented 9 years ago
Hello, 

First problem could be solved by sending access_type=offline when requesting 
request token.
See this article:
https://developers.google.com/accounts/docs/OAuth2WebServer

Original comment by Vitaliy....@conxgroup.com on 7 May 2014 at 7:17