Authorize() private method

使用授权码换取 AccessToken,并保存到缓存中。
private Authorize ( string authorizeCode ) : System.Threading.Tasks.Task
authorizeCode string
return System.Threading.Tasks.Task
 /// <summary>
 /// 创建分享对象,若需要,则弹出授权窗口。
 /// </summary>
 /// <returns>微博分享对象。</returns>
 /// <exception cref="AuthorizeException">用户取消授权获取授权过程中网络异常。</exception>
 /// <exception cref="HttpException">获取 AccessToken 过程中网络异常。</exception>
 public static async Task<WeiboClient> CreateAsync()
 {
     WeiboClient client = new WeiboClient();
     if (LocalAccessToken.Useable == false)
     {
         // 未授权或者授权已过期,请求重新授权。
         string authorizeCode = await client.GetAuthorizeCodeAsync();
         await client.Authorize(authorizeCode);
     }
     return client;
 }
Beispiel #2
0
        /// <summary>
        /// 创建分享对象,若需要,则弹出授权窗口。
        /// </summary>
        /// <returns>微博分享对象。</returns>
        /// <exception cref="AuthorizeException">用户取消授权获取授权过程中网络异常。</exception>
        /// <exception cref="HttpException">获取 AccessToken 过程中网络异常。</exception>
        public static async Task <WeiboClient> CreateAsync()
        {
            WeiboClient client = new WeiboClient();

            if (LocalAccessToken.Useable == false)
            {
                // 未授权或者授权已过期,请求重新授权。
                string authorizeCode = await client.GetAuthorizeCodeAsync();

                await client.Authorize(authorizeCode);
            }
            return(client);
        }