Beispiel #1
0
        /// <summary>
        /// 获取用户信息。
        /// </summary>
        /// <param name="authService">OAuth服务。</param>
        /// <param name="code">公众平台Code参数。</param>
        /// <returns>用户信息。</returns>
        public static OAuthUserInfo GetUserInfo(this IOAuthService authService, string code)
        {
            code.NotEmptyOrWhiteSpace("code");
            var result = authService.NotNull("authService").GetAccessToken(code);

            if (result == null)
            {
                throw new ArgumentException("根据 Code 获取访问票据失败。", "code");
            }
            return(authService.GetUserInfo(result, result.OpenId));
        }