calendarId didn't get encoded and return HttpError

43 views
Skip to first unread message

Ahmad

unread,
Mar 24, 2012, 11:25:17 AM3/24/12
to google-api-p...@googlegroups.com
when requesting 
calendar = service.calendars().get(calendarId='calendar_id').execute()
where calendar_id is the email address

i get 
<HttpError 404 when requesting https://www.googleapis.com/calendar/v3/calendars/<email_address_here>?alt=json returned "Not Found">

and noted that email address still have the @ didn't get replaced with %40, so I used the urllib.quote to get that done, but now I get the same error and the email address now have have %2540 instead of @ as if it is been quoted twice : @ > %40 > %2540

note that every thing was quite fine with no errors and I didn't touch that code for long time

Joe Gregorio

unread,
Mar 24, 2012, 11:44:02 AM3/24/12
to google-api-p...@googlegroups.com
The @ is a perfectly valid character to appear in the part of a URI:

http://tools.ietf.org/html/rfc3986#section-3.3

Did the permissions on that account change, which would account for the 404?

-joe

Ahmad

unread,
Mar 24, 2012, 1:12:58 PM3/24/12
to google-api-p...@googlegroups.com
Hey jcgregorio thnak you for helping,

Here what I have done,

I went to google calendar and changed calendar settings to be public then it worked with no errors,
then I changed the settings back and deleted the calendar and imported it again with no errors.

here I have 2 questions and I hope you can help me out:

1- should this request go fine even if the calendar settings isn't public as this request should be authorized by the user credentials?
2- regarding this case and one other case where I get AccessTokenRefresh error, I can see that the problem is some where with http or user credentials getting invalid, how can I refresh the access token manually without prompting the user to login to get new token so I can resolve the error when user isn't loged in? or this can be done some other way?

and many thanks again

Ahmad

unread,
Mar 24, 2012, 1:20:22 PM3/24/12
to google-api-p...@googlegroups.com
here is my code if it can help:
_______________________________________________________
storage = Storage(CredentialsModel, 'id', request.user, 'credential')
    flow = OAuth2WebServerFlow(
            client_id='00000000.apps.googleusercontent.com',
            client_secret=aaaaaaaaQ__-aaaaaaaaae',
            scope='https://www.googleapis.com/auth/calendar',
            user_agent='groupy/1.0',
            )
    credential = storage.get()
    if credential is None or credential.invalid == True:
        authorize_url = flow.step1_get_authorize_url(STEP2_URI)
        f = FlowModel(id=request.user, flow=flow)
        f.save()
        return HttpResponseRedirect(authorize_url)
    else:
        http = httplib2.Http()
        http = credential.authorize(http)
        service = build("calendar", "v3", http=http)
        calendar_id = request.user.email
        calendar = service.calendars().get(calendarId=calendar_id).execute()
________________________________________________________________


Joe Gregorio

unread,
Mar 24, 2012, 9:01:01 PM3/24/12
to google-api-p...@googlegroups.com
On Sat, Mar 24, 2012 at 1:12 PM, Ahmad <mygoo...@gmail.com> wrote:
> Hey jcgregorio thnak you for helping,
>
> Here what I have done,
>
> I went to google calendar and changed calendar settings to be public then it
> worked with no errors,
> then I changed the settings back and deleted the calendar and imported it
> again with no errors.
>
> here I have 2 questions and I hope you can help me out:
>
> 1- should this request go fine even if the calendar settings isn't public as
> this request should be authorized by the user credentials?

You will need to ask Calendar API specific questions on their forum:

https://groups.google.com/forum/?fromgroups#!forum/google-calendar-api

> 2- regarding this case and one other case where I get AccessTokenRefresh
> error, I can see that the problem is some where with http or user
> credentials getting invalid, how can I refresh the access token manually
> without prompting the user to login to get new token so I can resolve the
> error when user isn't loged in? or this can be done some other way?

Credentials objects will automatically request a new access_token as needed
when you go to make a request, there is no need to manually force a refresh.

-joe

>
> and many thanks again

Ahmad

unread,
Mar 26, 2012, 6:25:56 PM3/26/12
to google-api-p...@googlegroups.com
thanks for help joe

ahmad

Reply all
Reply to author
Forward
0 new messages