Example #1
0
 public OAuth1Settings(OAuth1Settings src)
 {
     ConsumerKey        = src.ConsumerKey;
     ConsumerSecrect    = src.ConsumerSecrect;
     AccessToken        = src.AccessToken;
     AccessTokenSecrect = src.AccessTokenSecrect;
     RequestTokenUrl    = src.RequestTokenUrl;
     AuthorizeUrl       = src.AuthorizeUrl;
     AccessTokenUrl     = src.AccessTokenUrl;
     CallbackUrl        = src.CallbackUrl;
     Debug_Nonce        = src.Debug_Nonce;
     Debug_Timestamp    = src.Debug_Timestamp;
 }
Example #2
0
 public OAuth1Settings(OAuth1Settings src)
 {
   ConsumerKey = src.ConsumerKey;
   ConsumerSecrect = src.ConsumerSecrect;
   AccessToken = src.AccessToken;
   AccessTokenSecrect = src.AccessTokenSecrect;
   RequestTokenUrl = src.RequestTokenUrl;
   AuthorizeUrl = src.AuthorizeUrl;
   AccessTokenUrl = src.AccessTokenUrl;
   CallbackUrl = src.CallbackUrl;
   Debug_Nonce = src.Debug_Nonce;
   Debug_Timestamp = src.Debug_Timestamp;
 }
Example #3
0
        public static void OAuth1Configure(this ISession session, OAuth1Settings settings)
        {
            // Ignore returned media types from servers when fetching request/access-tokens
            // (This is so silly: Twitter returning text/html when it is application/x-www-form-urlencoded.
            // See https://dev.twitter.com/discussions/5662)
            session.Service.CodecManager.AddFormUrlEncoded <OAuth1Token>(MediaType.Wildcard);

            Condition.Requires(settings.ConsumerKey, "settings.ConsumerKey").IsNotNull();
            Condition.Requires(settings.ConsumerSecrect, "settings.ConsumerSecrect").IsNotNull();
            Condition.Requires(settings.RequestTokenUrl, "settings.RequestTokenUrl").IsNotNull();
            Condition.Requires(settings.AuthorizeUrl, "settings.AuthorizeUrl").IsNotNull();
            Condition.Requires(settings.AccessTokenUrl, "settings.AccessTokenUrl").IsNotNull();

            session.RequestInterceptors.Add("OAuth", new OAuth1RequestInterceptor(settings));
        }
        public static void OAuth1Configure(this ISession session, OAuth1Settings settings)
        {
            // Ignore returned media types from servers when fetching request/access-tokens
              // (This is so silly: Twitter returning text/html when it is application/x-www-form-urlencoded.
              // See https://dev.twitter.com/discussions/5662)
              session.Service.CodecManager.AddFormUrlEncoded<OAuth1Token>(MediaType.Wildcard);

              Condition.Requires(settings.ConsumerKey, "settings.ConsumerKey").IsNotNull();
              Condition.Requires(settings.ConsumerSecrect, "settings.ConsumerSecrect").IsNotNull();
              Condition.Requires(settings.RequestTokenUrl, "settings.RequestTokenUrl").IsNotNull();
              Condition.Requires(settings.AuthorizeUrl, "settings.AuthorizeUrl").IsNotNull();
              Condition.Requires(settings.AccessTokenUrl, "settings.AccessTokenUrl").IsNotNull();

              session.RequestInterceptors.Add("OAuth", new OAuth1RequestInterceptor(settings));
        }
Example #5
0
        public static OAuth1Token OAuth1GetAccessTokenFromRequestToken(this ISession session, string verifier, bool rememberToken = true)
        {
            OAuth1Settings settings = GetExistingSettings(session);

            OAuth1Token token = session.Bind(settings.AccessTokenUrl, new { oauth_verifier = verifier })
                                .Accept <OAuth1Token>()
                                .Post()
                                .Body;

            if (rememberToken)
            {
                OAuth1SetAccessToken(session, token, true);
            }

            return(token);
        }
Example #6
0
        public static OAuth1Token OAuth1GetRequestToken(this ISession session, bool rememberToken = true)
        {
            OAuth1Settings settings = GetExistingSettings(session);

            OAuth1Token token = session.Request(settings.RequestTokenUrl)
                                .Accept <OAuth1Token>()
                                .Post()
                                .Body;

            if (rememberToken)
            {
                OAuth1SetAccessToken(session, token);
            }

            return(token);
        }
Example #7
0
        static void AuthorizeTwitterAccess_UsingOutOfBandPincode()
        {
            // Get Twitter API keys from file (don't want the secret parts hardcoded in public repository
              TwitterKeys keys = ReadKeys();

              // Configure OAuth1 with the stuff it needs for it's magic
              OAuth1Settings settings = new OAuth1Settings
              {
            ConsumerKey = keys.consumer_key,
            ConsumerSecrect = keys.consumer_secret,
            RequestTokenUrl = new Uri(Session.BaseUri, TwitterApi.OAuthRequestTokenPath),
            AuthorizeUrl = new Uri(Session.BaseUri, TwitterApi.OAuthAuthorizePath),
            AccessTokenUrl = new Uri(Session.BaseUri, TwitterApi.OAuthAccessTokenPath),
            CallbackUrl = "oob" // oob = Out Of Band
              };
              Session.OAuth1Configure(settings);

              // Attach a logger after settings has been assigned (use debugger for breakpoints inside it)
              Session.OAuth1Logger(new OAuth1Logger());

              // Get temporary credentials from Twitter (request token) and remember it internally
              OAuth1Token requestToken = Session.OAuth1GetRequestToken();

              // Ask user to authorize use of the request token
              Console.WriteLine("Now opening a browser with autorization info. Please follow instructions there.");
              Request authorizationRequest = Session.Bind(TwitterApi.OAuthAuthorizePath, requestToken);
              Process.Start(authorizationRequest.Url.AbsoluteUri);

              Console.WriteLine("Please enter Twitter pincode: ");
              string pincode = Console.ReadLine();

              if (!string.IsNullOrWhiteSpace(pincode))
              {
            // Get access credentials from Twitter
            Session.OAuth1GetAccessTokenFromRequestToken(pincode);
              }
        }
Example #8
0
 public OAuth1RequestInterceptor(OAuth1Settings settings)
 {
     Settings = new OAuth1Settings(settings);
 }
Example #9
0
 public SignatureHelper(OAuth1Settings settings, IOAuth1Logger logger)
 {
     Settings = settings;
     Logger   = logger;
 }
 public OAuth1RequestInterceptor(OAuth1Settings settings)
 {
     Settings = new OAuth1Settings(settings);
 }
Example #11
0
 public SignatureHelper(OAuth1Settings settings, IOAuth1Logger logger)
 {
     Settings = settings;
       Logger = logger;
 }
Example #12
0
 public void Log(OAuth1Settings settings, string message)
 {
 }