Esempio n. 1
0
        public static async Task <AuthToken> CreateOAuthTokenAsync(string appKey, string appSecret, string userName, string password, CancellationToken cancelToken)
        {
            var RequestTokenUrl = "http://api.t.sina.com.cn/oauth/request_token"; //<--these should get from resource
            var AuthorizeUrl    = "http://api.t.sina.com.cn/oauth/authorize";     //<--these should get from resource
            var AccessTokenUrl  = "http://api.t.sina.com.cn/oauth/access_token";  //<--these should get from resource

            IAuthTokenFactory oAuthTokenFactory = new JDCBOAuthTokenFactory       //<--this part could use ioc
            {
                AppKey          = appKey,
                AppSecret       = appSecret,
                RequestTokenUrl = RequestTokenUrl,
                AuthorizeUrl    = AuthorizeUrl,
                AccessTokenUrl  = AccessTokenUrl,
                UserName        = userName,
                Password        = password
            };

            return(await oAuthTokenFactory.CreateTokenAsync(cancelToken));
        }
Esempio n. 2
0
        public static async Task<AuthToken> CreateOAuthTokenAsync(string appKey, string appSecret, string userName, string password, CancellationToken cancelToken)
        {
            

            var RequestTokenUrl = "http://api.t.sina.com.cn/oauth/request_token"; //<--these should get from resource
            var AuthorizeUrl = "http://api.t.sina.com.cn/oauth/authorize"; //<--these should get from resource
            var AccessTokenUrl = "http://api.t.sina.com.cn/oauth/access_token"; //<--these should get from resource

            IAuthTokenFactory oAuthTokenFactory = new JDCBOAuthTokenFactory   //<--this part could use ioc 
            {
                AppKey = appKey,
                AppSecret = appSecret,
                RequestTokenUrl = RequestTokenUrl,
                AuthorizeUrl = AuthorizeUrl,
                AccessTokenUrl = AccessTokenUrl,
                UserName = userName,
                Password = password
            };
            return await oAuthTokenFactory.CreateTokenAsync(cancelToken);
        }