Reputation: 1294
Salam to all
I am using the DotNetOpenAuth control for authentication from google. This is the code that I am using.
<rp:OpenIdLogin ID="OID" runat=server Identifier="https://www.google.com/accounts/o8/id" RequestEmail="Require" ></rp:OpenIdLogin>
To get the response from the provider for the email ID I am using this code in the page load event of default.aspx
Public Email As String = "N/A"
Public FullName As String = "N/A"
Public Country As String = "N/A"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim openid As OpenIdRelyingParty = New OpenIdRelyingParty
Dim response = openid.GetResponse
If (Not (response) Is Nothing) Then
Select Case (response.Status)
Case AuthenticationStatus.Authenticated
Dim fetch = response.GetExtension
Dim email As String = String.Empty
If (Not (fetch) Is Nothing) Then
email = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email)
End If
FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, False)
End Select
End If
End Sub
I am able be authenticated with google, but there is no response of the email id from google.
Please tell me what exactly I am missing that is causing this problem.
Update
<configSections>
<section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true"/>
</configSections>
<dotNetOpenAuth>
<openid>
<relyingParty>
<behaviors>
<!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible
with OPs that use Attribute Exchange (in various formats). -->
<add type="DotNetOpenAuth.OpenId.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth" />
</behaviors>
</relyingParty>
</openid>
</dotNetOpenAuth>
Upvotes: 2
Views: 1448
Reputation: 81801
You're likely missing the appropriate "behavior" in your web.config file. Please study this page and apply it to your site: https://github.com/DotNetOpenAuth/DotNetOpenAuth/wiki/Enhancements
Also, when using this behavior, you should be looking for the ClaimsResponse
extension in the positive authentication response rather than FetchResponse
.
As a side note, you have a lot of boilerplate code in your code-behind's Page_Load
method that you don't need. The OpenIdControl
you're using has a LoggedIn
method that does most of what you're doing here (it gets you all the way to the body of your Case
block.
Upvotes: 2