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.
source share