Hey everyone,
I’ve got DotNetOpenId working to log in to Gmail accounts, but I’m running into a problem. I can’t seem to get any of the user’s info except for the ClaimedIdentifier.
I know it’s possible to get stuff like email addresses and usernames, but for some reason, I’m not getting any of those claims back. Has anyone here successfully pulled this kind of data from Gmail using DotNetOpenId?
If you’ve done this before, could you share how you set up your ClaimsRequest? I’m kind of stuck and would really appreciate an example or some pointers.
Thanks in advance for any help!
I’ve encountered this issue before when working with DotNetOpenId and Gmail. The problem often lies in the scope of permissions you’re requesting. Ensure you’re using the correct OpenID endpoint for Gmail, which is ‘https://www.google.com/accounts/o8/id’.
Additionally, you need to add the appropriate extensions to your request. Try incorporating the FetchRequest extension:
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
authRequest.AddExtension(fetch);
After authentication, you can retrieve the data using:
var fetchResponse = openid.GetExtension(response);
string email = fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Email);
Remember to handle cases where the user might not grant all requested permissions. Good luck with your implementation!
I’ve actually gone through a similar situation with DotNetOpenId and Gmail. The key is in how you set up your ClaimsRequest. Make sure you’re explicitly requesting the specific claims you want, like email and username.
Here’s what worked for me:
ClaimsRequest claims = new ClaimsRequest();
claims.AddRequired(WellKnownAttributes.Contact.Email);
claims.AddRequired(WellKnownAttributes.Name.FullName);
Then, when you’re making the authentication request, include these claims:
var authRequest = openid.CreateRequest(identifier, realm, returnToUrl);
authRequest.AddExtension(claims);
After authentication, you should be able to access these claims from the response. It took me a while to figure this out, so don’t get discouraged if it doesn’t work right away. Let me know if you need any more details!
hey CreativeArtist88, I ran into this too. make sure ur using the right endpoint for gmail (https://www.google.com/accounts/o8/id). also, try adding AX extension to ur request:
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
authRequest.AddExtension(fetch);
hope this helps! lmk if u need more info