示例#1
0
 /// <summary>
 /// Creates an instance of the DropNetClient given an API Key/Secret and a User Token/Secret
 /// Make sure to call AccountInfo() Method first, without the _userToken.ID field populated the api wont work. 
 /// </summary>
 /// <param name="apiKey">The Api Key to use for the Dropbox Requests</param>
 /// <param name="appSecret">The Api Secret to use for the Dropbox Requests</param>
 /// <param name="userToken">The User authentication token</param>
 /// <param name="userSecret">The Users matching secret</param>
 public GoodReadsClient(string apiKey, string appSecret, string userToken, string userSecret)
     : this(apiKey, appSecret)
 {
     _userLogin = new UserLogin( userToken,  userSecret );
     _restClient.Authenticator = AuthMethods();
     this.AccountInfo();
 }
示例#2
0
        public UserLogin GetAccessToken()
        {
            var request = new RestRequest("oauth/access_token", Method.POST);
            _restClient.Authenticator = OAuth1Authenticator.ForAccessToken(_apiKey, _appsecret, _userLogin.Token, _userLogin.Secret);
            var response = _restClient.Execute(request);

            var qs = HttpUtility.ParseQueryString(response.Content);
            var oauth_token = qs["oauth_token"];
            var oauth_token_secret = qs["oauth_token_secret"];

            _userLogin = new UserLogin(oauth_token, oauth_token_secret);

            return _userLogin;
        }
示例#3
0
        /// <summary>
        /// Gets a token from goodreads.com (Token cant be used until authorized!)
        /// </summary>
        /// <returns></returns>
        public UserLogin GetToken()
        {
            _restClient = new RestClient(ApiBaseUrl);
            _restClient.Authenticator = OAuth1Authenticator.ForRequestToken(_apiKey, _appsecret);
            var request = new RestRequest("oauth/request_token", Method.GET);
            var response = _restClient.Execute(request);

            var qs = HttpUtility.ParseQueryString(response.Content);
            var oauth_token = qs["oauth_token"];
            var oauth_token_secret = qs["oauth_token_secret"];

            _userLogin = new UserLogin(oauth_token, oauth_token_secret);

            return _userLogin;
        }