"Some requested scopes were invalid. {invalid=[Calendar]}"

1,443 views
Skip to first unread message

JTeagle

unread,
Feb 18, 2012, 5:36:19 AM2/18/12
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?

Alain Vongsouvanh

unread,
Feb 23, 2012, 5:54:47 PM2/23/12
to google-ca...@googlegroups.com
Hello,

In the GetAuthorization function, you should use:
  CalendarService.Scopes.Calendar.GetStringValue()

To get a valid scope value: 

Best,
Alain


--
You received this message because you are subscribed to the Google Groups "Google Calendar API" group.
To post to this group, send email to google-ca...@googlegroups.com.
To unsubscribe from this group, send email to google-calendar...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-calendar-api?hl=en.




--
Alain Vongsouvanh | Developer Programs Engineer

JTeagle

unread,
Feb 24, 2012, 3:55:06 AM2/24/12
to Google Calendar API
> In the GetAuthorization function, you should use:
>   CalendarService.Scopes.Calendar.GetStringValue()

Ugh, thanks - that fixed it. Silly mistake on my part!

--
Jason
Reply all
Reply to author
Forward
0 new messages