本文整理汇总了C#中DotNetOpenAuth.OpenId.Extensions.AttributeExchange.FetchRequest类的典型用法代码示例。如果您正苦于以下问题:C# FetchRequest类的具体用法?C# FetchRequest怎么用?C# FetchRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FetchRequest类属于DotNetOpenAuth.OpenId.Extensions.AttributeExchange命名空间,在下文中一共展示了FetchRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnBeforeSendingAuthenticationRequest
protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request)
{
var fetchRequest = new FetchRequest();
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
request.AddExtension(fetchRequest);
}
开发者ID:nimisha84,项目名称:SampleAppsForIPP_V2SDK,代码行数:7,代码来源:AuthConfig.cs
示例2: PrepareOpenIdRequest
internal AuthenticationResult PrepareOpenIdRequest(string providerUrl, Uri returnUrl)
{
Identifier identifier;
if (Identifier.TryParse(providerUrl, out identifier))
{
try
{
IAuthenticationRequest request = relyingParty.CreateRequest(identifier, Realm.AutoDetect, returnUrl);
FetchRequest fetch = new FetchRequest(); // request the authentication provider for some additional information.
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
request.AddExtension(fetch);
return new AuthenticationResult
{
Status = ConnectionStatus.RedirectToProvider,
Action = request.RedirectingResponse.AsActionResult()
};
}
catch (ProtocolException exception)
{
return AuthenticationException(exception);
}
}
return AbortedAuthentication(Common.Resources.Authentication.InvalidOpenIdIdentifier);
}
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:27,代码来源:OpenIdAuthenticationPortal.cs
示例3: RequestAuthentication
private Interfaces.IAuthenticationResponse RequestAuthentication(Interfaces.IAuthenticationRequest request)
{
Identifier id;
if (!Identifier.TryParse(request.Url, out id))
{
_logger.Info(string.Format("OpenID Error...invalid url. url='{0}'", request.Url));
return Factory.AuthenticationResponse(Interfaces.AuthenticationState.Errored);
}
try
{
var authenticationRequest = _openIdRelyingParty.CreateRequest(request.Url);
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
authenticationRequest.AddExtension(fetch);
var actionResult = authenticationRequest.RedirectingResponse.AsActionResult();
return Factory.AuthenticationResponse(actionResult);
}
catch (ProtocolException ex)
{
_logger.Error("OpenID Exception...", ex);
return Factory.AuthenticationResponse(Interfaces.AuthenticationState.Errored);
}
}
开发者ID:binarymash,项目名称:OpenIdDemo,代码行数:27,代码来源:AuthenticationProvider.cs
示例4: Login
public string Login(string callBackUrl)
{
var response = _openid.GetResponse();
if (response == null)
{
// Stage 2: user submitting Identifier
Identifier id;
if (Identifier.TryParse(OpenIdUrl, out id))
{
try
{
var callBackUri = new Uri(callBackUrl);
var request = _openid.CreateRequest(OpenIdUrl, new Realm(callBackUri), callBackUri);
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Middle);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Alias);
request.AddExtension(fetch);
request.RedirectToProvider();
return null;
}
catch (ProtocolException ex)
{
return null;
}
}
}
return null;
}
开发者ID:luuksommers,项目名称:lessthan,代码行数:35,代码来源:OpenIdLoginProvider.cs
示例5: LoginToGoogle
void LoginToGoogle()
{
try
{
using (OpenIdRelyingParty party = new OpenIdRelyingParty())
{
IAuthenticationRequest request = party.CreateRequest(ConfigurationManager.AppSettings["google-auth-path"]);
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
request.AddExtension(fetch);
//request.AddExtension(new ClaimsRequest
//{
// Country = DemandLevel.Request,
// Email = DemandLevel.Request,
// Gender = DemandLevel.Require,
// PostalCode = DemandLevel.Require,
// TimeZone = DemandLevel.Require,
//});
request.RedirectToProvider();
}
}
catch (ProtocolException ex)
{
LabelStatus.Text = ex.Message;
}
}
开发者ID:shamil-khan,项目名称:-net-practice,代码行数:30,代码来源:LoginView.cs
示例6: CreateFetchRequest
/// <summary>
/// Creates the fetch request.
/// </summary>
/// <returns></returns>
private static FetchRequest CreateFetchRequest()
{
var fetchRequest = new FetchRequest();
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
return fetchRequest;
}
开发者ID:edrex333,项目名称:OpenID,代码行数:11,代码来源:UserController.cs
示例7: OnBeforeSendingAuthenticationRequest
protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request)
{
FetchRequest extension = new FetchRequest();
extension.Attributes.AddRequired("http://axschema.org/contact/email");
extension.Attributes.AddRequired("http://axschema.org/namePerson");
request.AddExtension(extension);
}
开发者ID:mikalai-silivonik,项目名称:bnh,代码行数:7,代码来源:Yahoo.cs
示例8: OpenId
public ActionResult OpenId(string openIdUrl)
{
var response = _openid.GetResponse();
if (response == null)
{
// Stage 2: user submitting Identifier
Identifier id;
if (Identifier.TryParse(openIdUrl, out id))
{
try
{
var request = _openid.CreateRequest(openIdUrl);
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
request.AddExtension(fetch);
return request.RedirectingResponse.AsActionResult();
}
catch (ProtocolException)
{
//_logger.Error("OpenID Exception...", ex);
return this.RedirectToAction(x => x.SignIn());
}
}
//_logger.Info("OpenID Error...invalid url. url='" + openIdUrl + "'");
return this.RedirectToAction(x => x.SignIn());
}
// Stage 3: OpenID Provider sending assertion response
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
var fetch = response.GetExtension<FetchResponse>();
var firstName = "";
var lastName = "";
var email = "";
if (fetch != null)
{
firstName = fetch.GetAttributeValue(WellKnownAttributes.Name.First);
lastName = fetch.GetAttributeValue(WellKnownAttributes.Name.Last);
email = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);
}
return CreateUser(new CreateUser
{
UserName = response.ClaimedIdentifier,
FirstName = firstName,
LastName = lastName,
Email = email
});
case AuthenticationStatus.Canceled:
//_logger.Info("OpenID: Cancelled at provider.");
return this.RedirectToAction(x => x.SignIn());
case AuthenticationStatus.Failed:
//_logger.Error("OpenID Exception...", response.Exception);
return this.RedirectToAction(x => x.SignIn());
}
return this.RedirectToAction(x => x.SignIn());
}
开发者ID:wortexx,项目名称:notes,代码行数:59,代码来源:AccountController.cs
示例9: OnBeforeSendingAuthenticationRequest
/// <summary>
/// Called just before the authentication request is sent to service provider.
/// </summary>
/// <param name="request">
/// The request.
/// </param>
protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request) {
// Attribute Exchange extensions
var fetchRequest = new FetchRequest();
fetchRequest.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email, isRequired: true));
fetchRequest.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.FullName, isRequired: false));
request.AddExtension(fetchRequest);
}
开发者ID:vonbv,项目名称:dotnetopenid,代码行数:14,代码来源:YahooOpenIdClient.cs
示例10: Page_Load
/// <summary>
/// Action Results for Index, uses DotNetOpenAuth for creating OpenId Request with Intuit
/// and handling response recieved.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="e">Event Args.</param>
protected void Page_Load(object sender, EventArgs e)
{
//OpenId Relying Party
OpenIdRelyingParty openid = new OpenIdRelyingParty();
var openIdIdentifier = ConfigurationManager.AppSettings["openid_identifier"];
var response = openid.GetResponse();
if (response == null)
{
// Stage 2: user submitting Identifier
Identifier id;
if (Identifier.TryParse(openIdIdentifier, out id))
{
try
{
IAuthenticationRequest request = openid.CreateRequest(openIdIdentifier);
FetchRequest fetch = new FetchRequest();
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email));
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.FullName));
request.AddExtension(fetch);
request.RedirectToProvider();
}
catch (ProtocolException ex)
{
throw ex;
}
}
}
else
{
if (response.FriendlyIdentifierForDisplay == null)
{
Response.Redirect("/OpenIdHandler.aspx");
}
// Stage 3: OpenID Provider sending assertion response
Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay;
FetchResponse fetch = response.GetExtension<FetchResponse>();
if (fetch != null)
{
Session["OpenIdResponse"] = "True";
Session["FriendlyEmail"] = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);
Session["FriendlyName"] = fetch.GetAttributeValue(WellKnownAttributes.Name.FullName);
}
//Check if user disconnected from the App Center
if (Request.QueryString["disconnect"] != null && Request.QueryString["disconnect"].ToString(CultureInfo.InvariantCulture) == "true")
{
Session["Flag"] = true;
Response.Redirect("CleanupOnDisconnect.aspx");
}
else
{
Response.Redirect("Default.aspx");
}
}
}
开发者ID:julio,项目名称:IPP_Sample_Code,代码行数:63,代码来源:OpenIdHandler.aspx.cs
示例11: Index
/// <summary>
/// Action Results for Index, uses DotNetOpenAuth for creating OpenId Request with Intuit
/// and handling response recieved.
/// </summary>
/// <returns></returns>
public RedirectResult Index()
{
var openid_identifier = ConfigurationManager.AppSettings["openid_identifier"].ToString(); ;
var response = openid.GetResponse();
if (response == null)
{
// Stage 2: user submitting Identifier
Identifier id;
if (Identifier.TryParse(openid_identifier, out id))
{
try
{
IAuthenticationRequest request = openid.CreateRequest(openid_identifier);
FetchRequest fetch = new FetchRequest();
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email));
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.FullName));
request.AddExtension(fetch);
request.RedirectToProvider();
}
catch (ProtocolException ex)
{
throw ex;
}
}
}
else
{
if (response.FriendlyIdentifierForDisplay == null)
{
Response.Redirect("/OpenId");
}
// Stage 3: OpenID Provider sending assertion response, storing the response in Session object is only for demonstration purpose
Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay;
FetchResponse fetch = response.GetExtension<FetchResponse>();
if (fetch != null)
{
Session["OpenIdResponse"] = "True";
Session["FriendlyEmail"] = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);// emailAddresses.Count > 0 ? emailAddresses[0] : null;
Session["FriendlyName"] = fetch.GetAttributeValue(WellKnownAttributes.Name.FullName);//fullNames.Count > 0 ? fullNames[0] : null;
//get the Oauth Access token for the user from OauthAccessTokenStorage.xml
OauthAccessTokenStorageHelper.GetOauthAccessTokenForUser(Session["FriendlyEmail"].ToString(), this);
}
}
string query = Request.Url.Query;
if (!string.IsNullOrWhiteSpace(query) && query.ToLower().Contains("disconnect=true"))
{
Session["accessToken"] = "dummyAccessToken";
Session["accessTokenSecret"] = "dummyAccessTokenSecret";
Session["Flag"] = true;
return Redirect("/CleanupOnDisconnect/Index");
}
return Redirect("/Home/index");
}
开发者ID:nberisha,项目名称:QuickbooksV3API-DotNet-Mvc3-Sample,代码行数:62,代码来源:OpenIdController.cs
示例12: RedirectToProvider
public ActionResult RedirectToProvider(string providerUrl, string returnUrl, FetchRequest fetch)
{
var baseUrl = HttpContext.Current.Request.ToPublicUrl(new Uri("/", UriKind.Relative));
var realm = new Realm(baseUrl);
var authenticationRequest = _relyingParty.CreateRequest(providerUrl, realm, new Uri(returnUrl,UriKind.Absolute));
authenticationRequest.AddExtension(fetch);
return new OutgoingRequestActionResult(authenticationRequest.RedirectingResponse);
}
开发者ID:calebjenkins,项目名称:mobile-web,代码行数:9,代码来源:DefaultOpenIdRelyingParty.cs
示例13: RedirectToProvider
public ActionResult RedirectToProvider(string providerUrl, string returnUrl, FetchRequest fetch)
{
IAuthenticationRequest authenticationRequest = this.relyingParty.CreateRequest(providerUrl,
Realm.AutoDetect,
new Uri(returnUrl));
authenticationRequest.AddExtension(fetch);
return new OutgoingRequestActionResult(authenticationRequest.RedirectingResponse);
}
开发者ID:harimukkapati,项目名称:FootPrint,代码行数:9,代码来源:DefaultOpenIdRelyingParty.cs
示例14: OpenId
public ActionResult OpenId(LoginModel model)
{
Identifier id;
if (Identifier.TryParse(model.OpenID_Identifier, out id))
{
try
{
model.Config = _services.Config.Current;
var openId = new OpenIdRelyingParty();
returnToUrl = new Uri(Url.Action("OpenIdCallback", "Authentication", new { ReturnUrl = model.ReturnUrl }, Request.Url.Scheme), UriKind.Absolute);
// hack for google oauth2
if (model.OpenID_Identifier.Contains("google"))
{
client = new GoogleOAuth2Client(model.Config.ClientId, model.Config.ClientSecret);
client.RequestAuthentication(this.HttpContext, returnToUrl);
GoogleOAuth2Client.RewriteRequest();
return Redirect(returnToUrl.ToString());
}
else
{
var request = openId.CreateRequest(id, Realm.AutoDetect, returnToUrl);
// add request for name and email using sreg (OpenID Simple Registration
// Extension)
request.AddExtension(new ClaimsRequest
{
Email = DemandLevel.Require,
FullName = DemandLevel.Require,
Nickname = DemandLevel.Require
});
// also add AX request
var axRequest = new FetchRequest();
axRequest.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
axRequest.Attributes.AddRequired(WellKnownAttributes.Name.First);
axRequest.Attributes.AddRequired(WellKnownAttributes.Name.Last);
axRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
request.AddExtension(axRequest);
var redirectingResponse = request.RedirectingResponse;
return redirectingResponse.AsActionResult();
}
}
catch (ProtocolException ex)
{
model.Message = ex.Message;
return View("Login", model);
}
}
else
{
model.Message = "Invalid identifier";
return View("Login", model);
}
}
开发者ID:skyline9002,项目名称:NBlog,代码行数:56,代码来源:AuthenticationController.cs
示例15: OnBeforeSendingAuthenticationRequest
/// <summary>
/// Called just before the authentication request is sent to service provider.
/// </summary>
/// <param name="request">
/// The request.
/// </param>
protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request) {
// Attribute Exchange extensions
var fetchRequest = new FetchRequest();
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetchRequest.Attributes.AddOptional(WellKnownAttributes.Contact.HomeAddress.Country);
fetchRequest.Attributes.AddOptional(WellKnownAttributes.Name.First);
fetchRequest.Attributes.AddOptional(WellKnownAttributes.Name.Last);
request.AddExtension(fetchRequest);
}
开发者ID:raelyard,项目名称:dotnetopenid,代码行数:16,代码来源:GoogleOpenIdClient.cs
示例16: Authenticate
public ActionResult Authenticate(string returnUrl)
{
var openid = new OpenIdRelyingParty();
var response = openid.GetResponse();
if (response == null) {
// Stage 2: user submitting Identifier
Identifier id;
if (Identifier.TryParse(Request.Form["openid_identifier"], out id)) {
try {
var req = openid.CreateRequest(id);
var fetch = new FetchRequest();
//ask for more info - the email address
//no guarantee you'll get it back :)
var email = new AttributeRequest(WellKnownAttributes.Contact.Email);
email.IsRequired = true;
fetch.Attributes.Add(email);
req.AddExtension(fetch);
return req.RedirectingResponse.AsActionResult();
} catch (ProtocolException ex) {
ViewData["Message"] = ex.Message;
return View("Login");
}
} else {
ViewData["Message"] = "Invalid identifier";
return View("Login");
}
} else {
// Stage 3: OpenID Provider sending assertion response
switch (response.Status) {
case AuthenticationStatus.Authenticated:
//They're in there...
var fetch = response.GetExtension<FetchResponse>();
string email = null;
if (fetch != null) {
IList<string> emailAddresses = fetch.Attributes[WellKnownAttributes.Contact.Email].Values;
email = emailAddresses.Count > 0 ? emailAddresses[0] : null;
}
var friendly = email ?? response.FriendlyIdentifierForDisplay;
return AuthAndRedirect(friendly, response.ClaimedIdentifier);
case AuthenticationStatus.Canceled:
ViewData["Message"] = "Canceled at provider";
return View("Login");
case AuthenticationStatus.Failed:
ViewData["Message"] = response.Exception.Message;
return View("Login");
}
}
return new EmptyResult();
}
开发者ID:dancoppock,项目名称:MVC3-Starter-Site,代码行数:54,代码来源:SessionController.cs
示例17: Fetch
public void Fetch() {
var request = new FetchRequest();
request.Attributes.Add(new AttributeRequest(NicknameTypeUri));
request.Attributes.Add(new AttributeRequest(EmailTypeUri, false, int.MaxValue));
var response = new FetchResponse();
response.Attributes.Add(new AttributeValues(NicknameTypeUri, "Andrew"));
response.Attributes.Add(new AttributeValues(EmailTypeUri, "[email protected]", "[email protected]"));
ExtensionTestUtilities.Roundtrip(Protocol.Default, new[] { request }, new[] { response });
}
开发者ID:SachiraChin,项目名称:dotnetopenid,代码行数:11,代码来源:AttributeExchangeRoundtripTests.cs
示例18: Fetch
public async Task Fetch() {
var request = new FetchRequest();
request.Attributes.Add(new AttributeRequest(NicknameTypeUri));
request.Attributes.Add(new AttributeRequest(EmailTypeUri, false, int.MaxValue));
var response = new FetchResponse();
response.Attributes.Add(new AttributeValues(NicknameTypeUri, "Andrew"));
response.Attributes.Add(new AttributeValues(EmailTypeUri, "[email protected]", "[email protected]"));
await this.RoundtripAsync(Protocol.Default, new[] { request }, new[] { response });
}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:11,代码来源:AttributeExchangeRoundtripTests.cs
示例19: CreateRequest
public IAuthenticationRequest CreateRequest(string openidIdentifier)
{
var request = _openId.CreateRequest(openidIdentifier);
var fetchRequest = new FetchRequest();
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetchRequest.Attributes.AddOptional(WellKnownAttributes.Name.First);
fetchRequest.Attributes.AddOptional(WellKnownAttributes.Name.Last);
request.AddExtension(fetchRequest);
return request;
}
开发者ID:adamlepkowski,项目名称:nQA,代码行数:11,代码来源:OpenIdMembershipService.cs
示例20: btnGoogleLogin_Click
protected void btnGoogleLogin_Click(object sender, CommandEventArgs e)
{
string discoveryUri = e.CommandArgument.ToString();
OpenIdRelyingParty openid = new OpenIdRelyingParty();
var URIbuilder = new UriBuilder(Request.Url) { Query = "" };
var req = openid.CreateRequest(discoveryUri, URIbuilder.Uri, URIbuilder.Uri);
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
req.AddExtension(fetch);
req.RedirectToProvider();
}
开发者ID:bitpusher,项目名称:mocument,代码行数:12,代码来源:Login.aspx.cs
注:本文中的DotNetOpenAuth.OpenId.Extensions.AttributeExchange.FetchRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论