Comment #31 on issue 716 by
evilstee...@gmail.com: Execution of
Alright, I figured it out. Step by step instructions as follows - also see
the code I provided below. FYI, this runs in .Net 3.5 and unlike the
solution offered previously there are no new dependencies. You should be up
and running in no time.
1. If you haven't yet create your OAuth 2.0 credentials - I assume you
already know how to get those but here:
a) Log into your Google developer console:
http://console.developers.google.com
b) Create a project
c) Create your credentials - use 'installed application'
d) add the APIs that you need - I think Drive API is definitely
required. I also added Drive SDK just in case.
2. Copy the code below into VS and edit the first Main() method with your
client key and secret key.
3. Run the app and copy both the new access token and the refresh token.
Put those and your remaining credentials into the second Main() method
below.
4. You now should be able to run the second Main() method (just reverse the
naming). From now on that will be all you need - there is no need to re-run
the first Main() method.
BTW, the first Main() method below was found here:
https://developers.google.com/google-apps/spreadsheets/authorize
CODE:
using System;
using Google.GData.Client;
using Google.GData.Spreadsheets;
using Google.GData.Documents;
using System.Configuration;
using System.Collections.Specialized;
namespace GoogleSpreadsheet
{
class GoogleOAutho2
{
private static String folderName = "crazy.ivan";
static void Main(string[] args)
{
////////////////////////////////////////////////////////////////////////////
// STEP 1: Configure how to perform OAuth 2.0
////////////////////////////////////////////////////////////////////////////
// TODO: Update the following information with that obtained from
//
https://code.google.com/apis/console. After registering
// your application, these will be provided for you.
string CLIENT_ID = "your_client_id";
// This is the OAuth 2.0 Client Secret retrieved
// above. Be sure to store this value securely. Leaking this
// value would enable others to act on behalf of your application!
string CLIENT_SECRET = "your_secret_key"
// Space separated list of scopes for which to request access.
string SCOPE = "
https://www.googleapis.com/auth/drive
https://spreadsheets.google.com/feeds https://docs.google.com/feeds";
// This is the Redirect URI for installed applications.
// If you are building a web application, you have to set your
// Redirect URI at
https://code.google.com/apis/console.
string REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob";
string TOKEN_TYPE = "refresh";
////////////////////////////////////////////////////////////////////////////
// STEP 2: Set up the OAuth 2.0 object
////////////////////////////////////////////////////////////////////////////
// OAuth2Parameters holds all the parameters related to OAuth 2.0.
OAuth2Parameters parameters = new OAuth2Parameters();
// Set your OAuth 2.0 Client Id (which you can register at
//
https://code.google.com/apis/console).
parameters.ClientId = CLIENT_ID;
// Set your OAuth 2.0 Client Secret, which can be obtained at
//