WCF Data Services with URL in Request

I am working on configuring OAuth on WCF data services. I am having problems trying to query the data source for the provider user key, because in some cases the key is a URL. For example, for google https://www.google.com/accounts/o8/id?id=AItOawnDT8v-6rdRI221piLFbOBT1m3EYTizmDQ

I have the following function:

 public override int GetUserIdFromOAuth(string provider, string providerUserId) { var encodedUserId = Uri.EscapeDataString(providerUserId); var user = service.OAuthMemberships .Where(o => o.Provider == provider && o.ProviderUserId == encodedUserId) .SingleOrDefault(); if (user == null) return -1; return user.UserId; } 

It works great for twitter since ProviderUseId is just a number, but for google and yahoo, where UserId is the URL, I cannot combine it - it always brings 0 results, although I know that the URLs are the same. I avoid the URL (otherwise the request failed), but how can I find it, how should it?

===== Edit

I know that I can make it work by first asking the provider - make ToList (), and then request it to ProviderUserId - then it would not need to be encoded, since it would not be sent via DataServices. But I don’t like the idea of ​​pulling each record back for one provider over the cable, as a workaround.

+4
source share
1 answer

To move this, I installed a service operation to take care of this, but I'm still wondering if there is a β€œreal” answer to this question.

 [WebGet] public IEnumerable<OAuthMembership> GetOAuthUser(string provider, string providerUserId) { providerUserId = Uri.UnescapeDataString(providerUserId); using (var db = new WebsiteMembershipEntities()) { return db.OAuthMemberships.Where(o=>o.Provider == provider && o.ProviderUserId == providerUserId) .ToList(); } } 
0
source

All Articles