示例#1
0
 public AuthenticationProvider(string appName, string appId, string appSecret, IGraphLogger logger)
     : base(logger.NotNull(nameof(logger)).CreateShim(nameof(AuthenticationProvider)))
 {
     this.appName   = appName.NotNullOrWhitespace(nameof(appName));
     this.appId     = appId.NotNullOrWhitespace(nameof(appId));
     this.appSecret = appSecret.NotNullOrWhitespace(nameof(appSecret));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="UserPasswordAuthenticationProvider" /> class.
        /// </summary>
        /// <param name="appName">The application name.</param>
        /// <param name="appId">The application identifier.</param>
        /// <param name="appSecret">The application secret.</param>
        /// <param name="userName">The username to be used.</param>
        /// <param name="password">Password assoicated with the passed username.</param>
        /// <param name="logger">The logger.</param>
        public UserPasswordAuthenticationProvider(string appName, string appId, string appSecret, string userName, string password, IGraphLogger logger)
            : base(logger.NotNull(nameof(logger)).CreateShim(nameof(UserPasswordAuthenticationProvider)))
        {
            this.appName   = appName.NotNullOrWhitespace(nameof(appName));
            this.appId     = appId.NotNullOrWhitespace(nameof(appId));
            this.appSecret = appSecret.NotNullOrWhitespace(nameof(appSecret));

            this.userName = userName.NotNullOrWhitespace(nameof(userName));
            this.password = password.NotNullOrWhitespace(nameof(password));
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserPasswordAuthenticationProvider"/> class.
        /// </summary>
        /// <param name="appId">The application identifier.</param>
        /// <param name="appSecret">The application secret.</param>
        /// <param name="userName">The username to be used.</param>
        /// <param name="password">Password assoicated with the passed username.</param>
        /// <param name="logger">The logger.</param>
        public UserPasswordAuthenticationProvider(string appId, string appSecret, string userName, string password, IGraphLogger logger)
            : base(logger.NotNull(nameof(logger)).CreateShim(nameof(UserPasswordAuthenticationProvider)))
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(appId), $"Invalid {nameof(appId)}.");
            Debug.Assert(!string.IsNullOrWhiteSpace(appSecret), $"Invalid {nameof(appSecret)}.");
            Debug.Assert(!string.IsNullOrWhiteSpace(userName), $"Invalid {nameof(userName)}.");
            Debug.Assert(!string.IsNullOrWhiteSpace(password), $"Invalid {nameof(password)}.");

            this.AppId     = appId;
            this.AppSecret = appSecret;

            // NOTE: STORING USERNAME/PASSWORD IN A FILE IS NOT SAFE. THIS SAMPLE IS FOR DEMONSTRATION PURPOSE ONLY.
            this.UserName = userName;
            this.Password = password;
        }