JTeagle
unread,Feb 18, 2012, 5:36:19 AM2/18/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Calendar API
I'm trying to access Calendars v3 using the OAuth2 mechanism. The code
I'm using is basically what was in the sample:
NativeApplicationClient provider = new
NativeApplicationClient(GoogleAuthenticationServer.Description);
provider.ClientIdentifier = "as given by API Console for
installed application";
provider.ClientSecret = "as given by API Console for
installed application";
OAuth2Authenticator<NativeApplicationClient> auth = new
OAuth2Authenticator<NativeApplicationClient>(provider,
GetAuthorization);
CalendarService service = new CalendarService(auth);
CalendarList calendarList =
service.CalendarList.List().Fetch();
and:
private static IAuthorizationState
GetAuthorization(NativeApplicationClient arg)
{
// Get the auth URL:
IAuthorizationState state = new AuthorizationState(new[]
{ CalendarService.Scopes.Calendar.ToString() });
state.Callback = new
Uri(NativeApplicationClient.OutOfBandCallbackUrl);
Uri authUri =
arg.RequestUserAuthorization(state);
// Request authorization from the user (by opening a
browser window):
Process.Start(authUri.ToString());
Console.Write(" Authorization Code: ");
string authCode = Console.ReadLine();
Console.WriteLine();
// Retrieve the access token by using the authorization
code:
return arg.ProcessUserAuthorization(authCode, state);
}
When it comes to authorise the request, though, I get an 'invalid
scope' page. Any idea what I'm doing wrong?