Cannot create OAuth2 token for use with BigQuery

244 views
Skip to first unread message

Milan

unread,
Apr 24, 2012, 8:57:10 AM4/24/12
to BigQuery discuss
I am trying to create an OAuth2 token so that I can use the
BigQuery .Net API library. In order to create the token, I am using
the project 'Tasks.SimpleOAuth2' from the GoogleApisSamples code that
is downloadable from http://code.google.com/p/google-api-dotnet-client/wiki/Downloads.

When I run the program it takes me through the steps of entering the
Client ID, Client secret and the API key. Once I entered these details
in, I can see it creates a client.dat file in my user area.

It then navigates my browser to a Google page asking me to confirm the
permissions being requested. When I click Allow Access, I am taken to
a page with the authorization code. I enter this into the
Tasks.SimpleOAuth2 console application and it takes a few seconds
before coming back with the error:
--------------- Start of output ---------------
An error has occured:
Google.Apis.Requests.RequestError
Invalid Credentials [401]
Errors [
Message[Invalid Credentials] Location[Authorization - header]
Reason[aut
hError] Domain[global]
]

Press any key to display the stacktrace
--------------- End of output ---------------
When I view the stack trace, I get:
--------------- Start of output ---------------
The request 'Google.Apis.Requests.Request(list @ https://www.googleapis.com/tas
ks/v1/users/@me/lists?alt=json&prettyPrint=true)' has failed. The
service tasks
has thrown an exception: Google.GoogleApiRequestException:
Google.Apis.Requests.
RequestError
Invalid Credentials [401]
Errors [
Message[Invalid Credentials] Location[Authorization - header]
Reason[aut
hError] Domain[global]
]
---> System.Net.WebException: The remote server returned an error:
(401) Unauth
orized.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult
asyncResult)
at
Google.Apis.Requests.Request.InternalEndExecuteRequest(IAsyncResult
asyncR
esult) in d:\cygwin\home\Austin\apiary\google-api-dotnet-client
\3-16-2012\defaul
t\Src\GoogleApis\Apis\Requests\Request.cs:line 326
--- End of inner exception stack trace ---
at Google.Apis.Requests.Request.AsyncRequestResult.GetResponse() in
d:\cygwin
\home\Austin\apiary\google-api-dotnet-client\3-16-2012\default\Src
\GoogleApis\Ap
is\Requests\Request.cs:line 303
at Google.Apis.Requests.ServiceRequest`1.GetResponse() in d:\cygwin
\home\Aust
in\apiary\google-api-dotnet-client\3-16-2012\default\Src\GoogleApis
\Apis\Request
s\ServiceRequest.cs:line 183
at Google.Apis.Requests.ServiceRequest`1.Fetch() in d:\cygwin\home
\Austin\api
ary\google-api-dotnet-client\3-16-2012\default\Src\GoogleApis\Apis
\Requests\Serv
iceRequest.cs:line 203
at Google.Apis.Samples.TasksOAuth2.Program.Main(String[] args) in C:
\Users\ms\Downloads\GoogleSamples\Sample
\Tasks.SimpleOAuth2\Program.cs:line 74
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, C
ontextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Press any key to exit
--------------- End of output ---------------
Does anyone know what is going on here?

TIA

Michael Manoochehri

unread,
Apr 24, 2012, 12:50:08 PM4/24/12
to bigquery...@googlegroups.com
Hi Milan:

It looks like you are trying to make a call to the Tasks API instead of the BigQuery API. Are you using the correct BigQuery scope?
Have you enabled the BigQuery service in the Google API Dev Console?

- Michael
Reply all
Reply to author
Forward
0 new messages