当前位置: 首页>>代码示例>>C#>>正文


C# OAuth2.AuthorizationServerDescription类代码示例

本文整理汇总了C#中DotNetOpenAuth.OAuth2.AuthorizationServerDescription的典型用法代码示例。如果您正苦于以下问题:C# AuthorizationServerDescription类的具体用法?C# AuthorizationServerDescription怎么用?C# AuthorizationServerDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AuthorizationServerDescription类属于DotNetOpenAuth.OAuth2命名空间,在下文中一共展示了AuthorizationServerDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClientBase

		/// <summary>
		/// Initializes a new instance of the <see cref="ClientBase"/> class.
		/// </summary>
		/// <param name="authorizationServer">The token issuer.</param>
		/// <param name="clientIdentifier">The client identifier.</param>
		/// <param name="clientSecret">The client secret.</param>
		protected ClientBase(AuthorizationServerDescription authorizationServer, string clientIdentifier = null, string clientSecret = null) {
			Contract.Requires<ArgumentNullException>(authorizationServer != null);
			this.AuthorizationServer = authorizationServer;
			this.Channel = new OAuth2ClientChannel();
			this.ClientIdentifier = clientIdentifier;
			this.ClientSecret = clientSecret;
		}
开发者ID:enslam,项目名称:dotnetopenid,代码行数:13,代码来源:ClientBase.cs

示例2: Authorize

        public AuthorizeResult Authorize(Uri url, string username, string password)
        {
            var authServer = new AuthorizationServerDescription
            {
                AuthorizationEndpoint = null, // We are not actually using authorization, just authentication.
                TokenEndpoint = url
            };

            var client = new UserAgentClient(authServer, ClientIdentifier, ClientCredentialApplicator.PostParameter(ClientSecret));

            IAuthorizationState state;

            try
            {
                state = client.ExchangeUserCredentialForToken(username, password);
            }
            catch (Exception e)
            {
                var error = e.Message;

                if (e.InnerException != null)
                    error = string.Format("{0} Inner exception: {1}", error, e.InnerException.Message);

                return new AuthorizeResult
                {
                    Error = error
                };
            }

            return new AuthorizeResult
            {
                AuthorizationState = state
            };
        }
开发者ID:Kazetsukai,项目名称:Malone,代码行数:34,代码来源:OAuthApplication.cs

示例3: ProcessUserAuthorization

 public virtual IAuthorizationState ProcessUserAuthorization(
     WebServerClient authClient, AuthorizationServerDescription authServer, IServiceBase authService)
 {
     return HostContext.Config.StripApplicationVirtualPath
         ? authClient.ProcessUserAuthorization(authService.Request.ToHttpRequestBase())
         : authClient.ProcessUserAuthorization();
 }
开发者ID:BlakeRaymond-AI,项目名称:ServiceStack,代码行数:7,代码来源:OAuth2Provider.cs

示例4: GoogleOAuth2Authorization

        public GoogleOAuth2Authorization(ILogger log) : base(log)
        {
            Func<string, string> getConfigVal = (value) =>
                                                (ConfigurationManager.AppSettings.Get(value) ??
                                                 WebConfigurationManager.AppSettings.Get(value) ?? 
                                                 KeyStorage.Get(value));

            try
            {
                ClientID = getConfigVal("mail.googleClientID");
                ClientSecret = getConfigVal("mail.googleClientSecret");

                if (String.IsNullOrEmpty(ClientID)) throw new ArgumentNullException("ClientID");
                if (String.IsNullOrEmpty(ClientSecret)) throw new ArgumentNullException("ClientSecret");
            }
            catch (Exception ex)
            {
                log.Error("GoogleOAuth2Authorization() Exception:\r\n{0}\r\n", ex.ToString());
            }

            RedirectUrl = "urn:ietf:wg:oauth:2.0:oob";
 
            ServerDescription = new AuthorizationServerDescription
            {
                AuthorizationEndpoint = new Uri("https://accounts.google.com/o/oauth2/auth?access_type=offline"),
                TokenEndpoint = new Uri("https://accounts.google.com/o/oauth2/token"),
                ProtocolVersion = DotNetOpenAuth.OAuth2.ProtocolVersion.V20,
            };

            Scope = new List<string>
            {
                "https://mail.google.com/"
            };
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:34,代码来源:GoogleOAuth2Authorization.cs

示例5: CreateOAuth2Client

 private WebServerClient CreateOAuth2Client() {
     var serverDescription = new AuthorizationServerDescription {
         TokenEndpoint = new Uri(tokenEndpointTextBox.Text)
     };
     var client = new WebServerClient(serverDescription, oauth2ClientIdTextBox.Text, oauth2ClientSecretTextBox.Text);
     return (client);
 }
开发者ID:chengming0916,项目名称:OAuthStack,代码行数:7,代码来源:Form1.cs

示例6: NativeApplicationClient

 /// <summary>
 /// Initializes a new instance of the <see cref="UserAgentClient"/> class.
 /// </summary>
 /// <param name="authorizationServer">The token issuer.</param>
 /// <param name="clientIdentifier">The client identifier.</param>
 /// <param name="clientSecret">The client secret.</param>
 public NativeApplicationClient(
     AuthorizationServerDescription authorizationServer,
     string clientIdentifier,
     string clientSecret)
     : base(authorizationServer, clientIdentifier, clientSecret)
 {
 }
开发者ID:Ruddylee,项目名称:sharePhoto,代码行数:13,代码来源:NativeApplicationClass.cs

示例7: ClientBase

		/// <summary>
		/// Initializes a new instance of the <see cref="ClientBase"/> class.
		/// </summary>
		/// <param name="authorizationServer">The token issuer.</param>
		/// <param name="clientIdentifier">The client identifier.</param>
		/// <param name="clientSecret">The client secret.</param>
		protected ClientBase(AuthorizationServerDescription authorizationServer, string clientIdentifier = null, string clientSecret = null) {
			Requires.NotNull(authorizationServer, "authorizationServer");
			this.AuthorizationServer = authorizationServer;
			this.Channel = new OAuth2ClientChannel();
			this.ClientIdentifier = clientIdentifier;
			this.ClientSecret = clientSecret;
		}
开发者ID:SachiraChin,项目名称:dotnetopenid,代码行数:13,代码来源:ClientBase.cs

示例8: Button1_Click

        protected async void Button1_Click(object sender, EventArgs e)
        {
            var authServer = new AuthorizationServerDescription()
            {
                
                TokenEndpoint = new Uri("http://localhost:53022/OAuth/token "),
                ProtocolVersion = ProtocolVersion.V20
            };
            WebServerClient Client= new WebServerClient(authServer, "idefav", "1");

            var code =await Client.GetClientAccessTokenAsync(new string[] { "http://localhost:55045/IService1/DoWork" });
            string token = code.AccessToken;
            Service1Reference.Service1Client service1Client=new Service1Client();
            var httpRequest = (HttpWebRequest)WebRequest.Create(service1Client.Endpoint.Address.Uri);
            ClientBase.AuthorizeRequest(httpRequest,token);
            var httpDetails = new HttpRequestMessageProperty();
            httpDetails.Headers[HttpRequestHeader.Authorization] = httpRequest.Headers[HttpRequestHeader.Authorization];
            
            using (var scope = new OperationContextScope(service1Client.InnerChannel))
            {
                
                if (OperationContext.Current.OutgoingMessageProperties.ContainsKey(HttpRequestMessageProperty.Name))
                {
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpDetails;
                }
                else
                {
                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpDetails);
                }
                
                Button1.Text= service1Client.DoWork();
            }


        }
开发者ID:idefav,项目名称:IdefavOAuth2Demo,代码行数:35,代码来源:Default.aspx.cs

示例9: ClientBase

		/// <summary>
		/// Initializes a new instance of the <see cref="ClientBase" /> class.
		/// </summary>
		/// <param name="authorizationServer">The token issuer.</param>
		/// <param name="clientIdentifier">The client identifier.</param>
		/// <param name="clientCredentialApplicator">The tool to use to apply client credentials to authenticated requests to the Authorization Server.
		/// May be <c>null</c> for clients with no secret or other means of authentication.</param>
		/// <param name="hostFactories">The host factories.</param>
		protected ClientBase(AuthorizationServerDescription authorizationServer, string clientIdentifier = null, ClientCredentialApplicator clientCredentialApplicator = null, IHostFactories hostFactories = null) {
			Requires.NotNull(authorizationServer, "authorizationServer");
			this.AuthorizationServer = authorizationServer;
			this.Channel = new OAuth2ClientChannel(hostFactories);
			this.ClientIdentifier = clientIdentifier;
			this.ClientCredentialApplicator = clientCredentialApplicator;
		}
开发者ID:Crypth,项目名称:DotNetOpenAuth,代码行数:15,代码来源:ClientBase.cs

示例10: CreateGoogleClientAction

 /// <summary>
 /// Initializes a new instance of the <see cref="CreateGoogleClientAction"/> class.
 /// </summary>
 /// <param name="authorizationDescription"></param>
 /// <param name="membershipProvider">The build motion provider.</param>
 public CreateGoogleClientAction(AuthorizationServerDescription authorizationDescription, MembershipProviderBase membershipProvider)
     : base(membershipProvider)
 {
     this.authorizationDescription = authorizationDescription;
     //PATTERN: setup in constructor to allow for action validation on fields/properties;
     this.clientId = this.Provider.GoogleClientId;
     this.clientSecret = this.Provider.GoogleClientSecret;
 }
开发者ID:virajs,项目名称:GoogleOAuthMvcMembershipProvider,代码行数:13,代码来源:CreateGoogleClientAction.cs

示例11: GetAuthServerDescription

 public static AuthorizationServerDescription GetAuthServerDescription()
 {
     var authServerDescription = new AuthorizationServerDescription();
     authServerDescription.AuthorizationEndpoint = new Uri(@"https://accounts.google.com/o/oauth2/auth");
     authServerDescription.TokenEndpoint = new Uri(@"https://accounts.google.com/o/oauth2/token");
     authServerDescription.ProtocolVersion = ProtocolVersion.V20;
     return authServerDescription;
 }
开发者ID:julianjelfs,项目名称:geeks,代码行数:8,代码来源:ImportController.cs

示例12: PerformAction

 /// <summary>
 ///   Does this instance.
 /// </summary>
 public override void PerformAction()
 {
     authServerDescription = new AuthorizationServerDescription();
     // Add the access_type parameter sot that the RefreshToken is returned along with the AccessTokein
     authServerDescription.AuthorizationEndpoint = new Uri(@"https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force");
     authServerDescription.TokenEndpoint = new Uri(@"https://accounts.google.com/o/oauth2/token");
     authServerDescription.ProtocolVersion = ProtocolVersion.V20;
 }
开发者ID:virajs,项目名称:GoogleOAuthMvcMembershipProvider,代码行数:11,代码来源:GetAuthServerDescriptionAction.cs

示例13: HomeController

 public HomeController() {
     var authServer = new AuthorizationServerDescription() {
         AuthorizationEndpoint = new Uri("http://localhost:49810/OAuth/Authorise"),
         TokenEndpoint = new Uri("http://localhost:49810/OAuth/Token"),
     };
     this.Client = new UserAgentClient(authServer, "samplewebapiconsumer", "samplesecret");
     this.Authorization = new AuthorizationState();
     this.Authorization.Callback = new Uri("http://localhost:18529/");
 }
开发者ID:thekane,项目名称:DotNetOpenAuth.WebAPI,代码行数:9,代码来源:HomeController.cs

示例14: Main

        private static void Main()
        {
            // DotNetOpenAuth only issues access tokens when the client uses an HTTPS connection. As we will most
            // likely run the server on our local development machine with only a self-signed SSL certificate, setting up 
            // connection to the server will fail as the SSL certificate is considered invalid by the .NET framework. 
            // To circumvent this, we add the line below that will consider all SSL certificates as valid, including
            // self-signed certificaties. Note: this should only be used for testing purposes.
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;

            // The description of the authorization server to which we will be connecting. The most important component
            // is the token endpoint, which is the URL at which the server listens for token requests
            var authorizationServerDescription = new AuthorizationServerDescription
                                                     {
                                                         TokenEndpoint = new Uri("https://localhost:44303/tokens"),
                                                         ProtocolVersion = ProtocolVersion.V20
                                                     };

            // Create the client with which we will be connecting to the server.
            var userAgentClient = new UserAgentClient(authorizationServerDescription, clientIdentifier: "demo-client-1", clientSecret: "demo-client-secret-1");

            // The scope that we request for the client. Note: this can also be null if we don't want to request any specific 
            // scope or more than one scope if we want to request an access token that is valid for several scopes
            var clientScopes = new[] { "demo-scope-client-1" };

            // Request a new client access token for the specified scopes (http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.4)
            // This method will use the client identifier and client secret used when constructing the UserAgentClient instance
            var clientAccessToken = userAgentClient.GetClientAccessToken(clientScopes);

            // Output some information about the retrieved client access token
            Console.WriteLine("[RETRIEVED CLIENT ACCESS TOKEN]");
            Console.WriteLine("Access token: {0}", clientAccessToken.AccessToken);
            Console.WriteLine("Expiration time: {0}", clientAccessToken.AccessTokenExpirationUtc);
            Console.WriteLine("Scope: {0}",  OAuthUtilities.JoinScopes(clientAccessToken.Scope));

            // The scope that we request for the user. Note: this can also be null if we don't want to request any specific 
            // scope or more than one scope if we want to request an access token that is valid for several scopes
            var userScopes = new[] { "demo-scope-1" };

            // Request a new user access token for the specified user and the specified scopes (http://tools.ietf.org/html/draft-ietf-oauth-v2-31#page-35)
            var userAccessToken = userAgentClient.ExchangeUserCredentialForToken("demo-user-1", "demo-user-password-1", userScopes);

            // Output some information about the retrieved user access token
            Console.WriteLine("\n[RETRIEVED USER ACCESS TOKEN]");
            Console.WriteLine("Access token: {0}", userAccessToken.AccessToken);
            Console.WriteLine("Refresh token: {0}", userAccessToken.RefreshToken);
            Console.WriteLine("Expiration time: {0}", userAccessToken.AccessTokenExpirationUtc);
            Console.WriteLine("Scope: {0}", OAuthUtilities.JoinScopes(userAccessToken.Scope));

            var refreshed = userAgentClient.RefreshAuthorization(userAccessToken);

            Console.WriteLine("\n[REFRESHING USER ACCESS TOKEN]");
            Console.WriteLine("Access token refreshed: {0}", refreshed);

            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();
        }
开发者ID:shahshyam,项目名称:basicoauth2server.persistent,代码行数:56,代码来源:Program.cs

示例15: InitializeWebServerClient

 private void InitializeWebServerClient()
 {
     var authorizationServerUri = new Uri("http://localhost:11625");
     var authorizationServer = new AuthorizationServerDescription
     {
         AuthorizationEndpoint = new Uri(authorizationServerUri, "/OAuth/Authorize"),
         TokenEndpoint = new Uri(authorizationServerUri, "/OAuth/Token")
     };
     _webServerClient = new WebServerClient(authorizationServer, "123456", "abcdef");
 }
开发者ID:Kristinn-Stefansson,项目名称:raml-dotnet-tools,代码行数:10,代码来源:HomeController.cs


注:本文中的DotNetOpenAuth.OAuth2.AuthorizationServerDescription类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。