protected void createAndSendLoginRequest(DossiaOpenID dossiaOpenID, OpenIdClient openIdClient, Boolean reqAttributes, Boolean reqOauthToken) { dossiaOpenID.InitializeForSending(openIdClient); // see http://docs.dossia.org/index.php/Dossia_OpenID_Consumer_Developer_Guide#Attributes_Available_via_OpenID // for list of available attributes if (reqAttributes) { AttributeExchange attributeExchange = new AttributeExchange(openIdClient); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/address1", "address1", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/address2", "address2", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/city", "city", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/dateOfBirth", "dateOfBirth", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/email", "email", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/employeeId", "employeeId", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/employer", "employer", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/firstName", "firstName", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/gender", "gender", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/lastName", "lastName", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/middleName", "middleName", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/postalCode", "postalCode", 1, true); attributeExchange.AddFetchItem("http://openid.dossia.org/participant/state", "state", 1, true); } if (reqOauthToken) { OAuthClient oauthClient = DossiaOauth.createDossiaOAuthClient(); OAuthExtension oauthext = new OAuthExtension(openIdClient, oauthClient); } openIdClient.CreateRequest(false, true); }
protected void openid_ValidationSucceeded(object sender, EventArgs e) { // User has been validated! Respond appropriately. OpenIdClient openIdClient = (OpenIdClient)sender; OpenIdUser openIdUser = openIdClient.RetrieveUser(); LoginInfo loginInfo = new LoginInfo(); loginInfo.openID = openIdUser.BaseIdentity; loginInfo.extensionData = openIdUser.ExtensionData; OAuthClient oauthClient = DossiaOauth.createDossiaOAuthClient(); OAuthExtension oauthExtension = new OAuthExtension(openIdClient, oauthClient); loginInfo.accessToken = oauthExtension.GetAccessToken(); Session["loginInfo"] = loginInfo; Response.Redirect("Default.aspx", true); }