public RequestUserAuthorization ( IEnumerable |
||
scope | IEnumerable |
The scope of authorized access requested. |
returnTo | The URL the authorization server should redirect the browser (typically on this site) to when the authorization is completed. If null, the current request's URL will be used. | |
Résultat | void |
public void RequestUserAuthorization(IEnumerable<string> scope = null, Uri returnTo = null) {
var authorizationState = new AuthorizationState(scope) {
Callback = returnTo,
};
this.PrepareRequestUserAuthorization(authorizationState).Send();
}
/// <summary> /// 使用DotNetOpenOAuth组件来模拟授权 /// </summary> /// <returns></returns> public ActionResult TestAuthorize() { var authServer = new AuthorizationServerDescription { AuthorizationEndpoint = new Uri("http://localhost:3335/OAuth/Authorize"), TokenEndpoint = new Uri("http://localhost:3335/OAuth/Token") }; var autoServerClient = new DotNetOpenAuth.OAuth2.WebServerClient(authServer, clientIdentifier: "fNm0EDIXbfuuDowUpAoq5GTEiywV8eg0TpiIVnV8", clientSecret: "clientSecret"); autoServerClient.RequestUserAuthorization(new string[] { "scope1" }, new Uri("http://localhost:3335/OAuth/GetAccessToken")); return(new EmptyResult()); }