Dhruti90 / google-gdata1111

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Result of DocumentEntry.AccessControlList Changed, causing Acl query to fail #314

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Retrieve a instance of the Document class using 2 legged oauth
2. Get an instance of the AclQuery class using the AccessControlList 
property of the document object
3. Query the Acl query using 2 legged oauth

What is the expected output? What do you see instead?

Something has changed with the AccessControlList property of the 
DocumentEntry Class.  I'm not sure if the API has changed its output or 
not, but now the property includes the "xoauth_requestor_id=[user]" query 
parameter.  As early as a few weeks ago it did not.  

Before, I would get an Acl list as follows:

<<<<<<<<<<<<<<<<<<<<<<<
Dim aclQuery as New AclQuery(document.DocumentEntry.AccessControlList)
aclQuery.OAuthRequestorID = "user@example.org"
Dim aclFeed = _docsService.Query(aclQuery)
>>>>>>>>>>>>>>>>>>>>>>>>

...The call to OAuthRequestorID would change the Uri to include the 
xoauth_requestor_id property.  Now the xoauth_requestor_id query property 
is included in the DocumentEntry.AccessControlList property, so that now 
when I set aclQuery.OAuthRequestorID = "user@example.org", the 
xoauth_requestor_id is put in the Uri twice; causing the query to fail.  If 
I don't set the OauthRequestorID property, the query doesn't know to use 2-
Legged OAuth, and the query fails.

To make a temporary workaround, I've changed my user code to the following:
<<<<<<<<<<<<<<<<<<<<<<<<
Dim aclQuery as New 
AclQuery(document.DocumentEntry.AccessControlList.Replace("xoauth_requestor
_id=user@example.org, ""))
aclQuery.OAuthRequestorID = "user@example.org"
Dim aclFeed = _docsService.Query(aclQuery)
>>>>>>>>>>>>>>>>>>>>>>>>

...Not very elegant.  

Can we change the AclQuery constructor to sense when the Uri has a 
xoauth_requestor_id query parameter in it, so that it automatically knows 
to use OAuth, without setting OAuthRequestorId? 

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by edwin.la...@gmail.com on 15 Jan 2010 at 12:09

GoogleCodeExporter commented 9 years ago
I will take a look at this.

Original comment by fman...@gmail.com on 20 Jan 2010 at 10:19

GoogleCodeExporter commented 9 years ago
Long time, but here we go. There was already code to protect against this, but 
in cases where the to be 
appended query paramter was already in the URI with a different append char ( ? 
vs & ) it failed. Fixed that. Hope 
this helps, please sync code and verify.

Original comment by fman...@gmail.com on 19 Mar 2010 at 4:01

GoogleCodeExporter commented 9 years ago
Hey Frank,

The xoauth_requestor_id query parameter is now not showing up twice in the 
feedquery, 
but it still doesn't work.  I get a 401 error.  But, my workaround of replacing 
the 
xoauth query parameter with an empty string before passing the feed uri into 
the 
aclquery constructor still works.  

I'm not intimate with the internals of the feedquery/service, but it appears 
like the 
query doesn't know to use oauth in the request.  The code won't work even if 
you 
change the aclquery's oAuthRequestorID property to an empty string and then 
back 
again, so there must be something strange in the constructor or in an Event 
triggered 
when the oAuthRequestorID property is set?:

<<<<<
' Below still fails
Dim aclQuery As New AclQuery (document.DocumentEntry.AccessControlList)
aclQuery.OAuthRequestorID = ""
aclQuery.OAuthRequestorID = "user@example.org"
>>>>>>>>

If I have some time, I'll look more deeply later this weekend, but it's a 
longshot 
that I'll find the culprit.

Original comment by edwin.la...@gmail.com on 20 Mar 2010 at 6:03

GoogleCodeExporter commented 9 years ago
I found success by using an empty constructor with the AclQuery Class:
<<<<<<<<
Dim aclQuery As New AclQuery ()
aclQuery.Uri = document.AccessControlList

>>>>>>>>>>

I read in the code comments that when the FeedQuery is passed a Uri when it is 
initialized, the Uri isn't parsed.  The explanation for this is that parsing is 
not 
available on mobile platforms.  I think I understand the problem, but this 
behavior 
is not intuitive to the User.  

To make the functionality more clear, I've got a couple of suggestions:

1. Parse the uri in the constructor and place logic in there so that it behaves 
differently for mobile platforms, or
2. Let the class's users know about the behavior in the "/// <summary>" section 
of 
the Query Classes 

What do you think?  

Original comment by edwin.la...@gmail.com on 21 Mar 2010 at 6:06