[twitter-dev] iPhone::Incorrect oauth_signature for xAuth?

2010-09-12 Thread Nikolay Klimchuk
I'm trying to understand why algorithm for calculation of
oauth_signature does not give me the same result as shown here:
http://dev.twitter.com/pages/xauth

In my case I'm getting signedSK = 'MUYmiobRdoK6s0ZVqo4xQNNO17w='

If I URL encode such result it's still very different from
yUDBrcMMm6ghqBEKCFKVoJPIacU%3D

I've tried different implementations, all of them give the same
result. After few hours of exercises with all this stuff I completely
run out of ideas, please help

// Test with input data taken from Twitter page

NSString *s= @POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
%2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
%26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
%3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
%26x_auth_password%3D%2525%2526123%2521aZ%252B
%2528%2529456242134%26x_auth_username%3DtpFriendlyGiant;

NSString *k = @5kEQypKe7lFHnufLtsocB1vAzO07xLFgp2Pc4sp2vk;

NSString *signedSK = [NetworkManager base64forData:[NetworkManager
HMACSHA1withKey:k forString:s]];

// Source code


+ (NSData *)HMACSHA1withKey:(NSString *)key forString:(NSString
*)string
{
NSData *clearTextData = [string
dataUsingEncoding:NSUTF8StringEncoding];
NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding];

uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};

CCHmacContext hmacContext;
CCHmacInit(hmacContext, kCCHmacAlgSHA1, keyData.bytes,
keyData.length);
CCHmacUpdate(hmacContext, clearTextData.bytes,
clearTextData.length);
CCHmacFinal(hmacContext, digest);

return [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
}

//Source http://www.cocoadev.com/index.pl?BaseSixtyFour

+ (NSString *)base64forData:(NSData *)data
{
static const char encodingTable[] =
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/;

if ([data length] == 0)
return @;

char *characters = malloc((([data length] + 2) / 3) * 4);
if (characters == NULL)
return nil;
NSUInteger length = 0;

NSUInteger i = 0;
while (i  [data length])
{
char buffer[3] = {0,0,0};
short bufferLength = 0;
while (bufferLength  3  i  [data length])
buffer[bufferLength++] = ((char *)[data bytes])[i++];

//  Encode the bytes in the buffer to four characters,
including padding = characters if necessary.
characters[length++] = encodingTable[(buffer[0]  0xFC)  2];
characters[length++] = encodingTable[((buffer[0]  0x03)  4)
| ((buffer[1]  0xF0)  4)];
if (bufferLength  1)
characters[length++] = encodingTable[((buffer[1]  
0x0F)  2) |
((buffer[2]  0xC0)  6)];
else characters[length++] = '=';
if (bufferLength  2)
characters[length++] = encodingTable[buffer[2]  0x3F];
else characters[length++] = '=';
}

return [[[NSString alloc] initWithBytesNoCopy:characters
length:length encoding:NSASCIIStringEncoding freeWhenDone:YES]
autorelease];
}

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en


[twitter-dev] Re: iPhone::Incorrect oauth_signature for xAuth?

2010-09-13 Thread Nikolay Klimchuk
Thank you Tom

I will try your algorithm and compare results.
Quick question: why you do this [str substringToIndex:[str
length]-3] ?

Nikolay Klimchuk

On Sep 13, 2:46 am, Tom van der Woerdt i...@tvdw.eu wrote:
 Hi Nikolay,

 The first part of your code looks fine. You may, however, like to do
 some debugging on the HMAC part - it looks a bit too simple to me.

 This works :
         NSString *compKey = [NSString 
 stringWithFormat:@%@%@,secret,userSecret];
         const char *cKey = [compKey 
 cStringUsingEncoding:NSUTF8StringEncoding];
         const char *cData = [[str substringToIndex:[str length]-3]
 cStringUsingEncoding:NSUTF8StringEncoding];
         unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];
         CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData, strlen(cData), 
 cHMAC);
         NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC 
 length:sizeof(cHMAC)];
 (str being the Base String)

 Hope it helps :-)

 Tom

 On 9/13/10 3:02 AM, Nikolay Klimchuk wrote:



  I'm trying to understand why algorithm for calculation of
  oauth_signature does not give me the same result as shown here:
 http://dev.twitter.com/pages/xauth

  In my case I'm getting signedSK = 'MUYmiobRdoK6s0ZVqo4xQNNO17w='

  If I URL encode such result it's still very different from
  yUDBrcMMm6ghqBEKCFKVoJPIacU%3D

  I've tried different implementations, all of them give the same
  result. After few hours of exercises with all this stuff I completely
  run out of ideas, please help

  // Test with input data taken from Twitter page

  NSString *s= @POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
  %2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
  %26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
  %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
  %3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
  %26x_auth_password%3D%2525%2526123%2521aZ%252B
  %2528%2529456242134%26x_auth_username%3DtpFriendlyGiant;

  NSString *k = @5kEQypKe7lFHnufLtsocB1vAzO07xLFgp2Pc4sp2vk;

  NSString *signedSK = [NetworkManager base64forData:[NetworkManager
  HMACSHA1withKey:k forString:s]];

  // Source code

  + (NSData *)HMACSHA1withKey:(NSString *)key forString:(NSString
  *)string
  {
     NSData *clearTextData = [string
  dataUsingEncoding:NSUTF8StringEncoding];
     NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding];

     uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};

     CCHmacContext hmacContext;
     CCHmacInit(hmacContext, kCCHmacAlgSHA1, keyData.bytes,
  keyData.length);
     CCHmacUpdate(hmacContext, clearTextData.bytes,
  clearTextData.length);
     CCHmacFinal(hmacContext, digest);

     return [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
  }

  //Sourcehttp://www.cocoadev.com/index.pl?BaseSixtyFour

  + (NSString *)base64forData:(NSData *)data
  {
      static const char encodingTable[] =
  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/;

      if ([data length] == 0)
          return @;

      char *characters = malloc((([data length] + 2) / 3) * 4);
      if (characters == NULL)
          return nil;
      NSUInteger length = 0;

      NSUInteger i = 0;
      while (i  [data length])
      {
          char buffer[3] = {0,0,0};
          short bufferLength = 0;
          while (bufferLength  3  i  [data length])
                     buffer[bufferLength++] = ((char *)[data bytes])[i++];

          //  Encode the bytes in the buffer to four characters,
  including padding = characters if necessary.
          characters[length++] = encodingTable[(buffer[0]  0xFC)  2];
          characters[length++] = encodingTable[((buffer[0]  0x03)  4)
  | ((buffer[1]  0xF0)  4)];
          if (bufferLength  1)
                     characters[length++] = encodingTable[((buffer[1]  0x0F) 
   2) |
  ((buffer[2]  0xC0)  6)];
          else characters[length++] = '=';
          if (bufferLength  2)
                     characters[length++] = encodingTable[buffer[2]  0x3F];
          else characters[length++] = '=';
      }

      return [[[NSString alloc] initWithBytesNoCopy:characters
  length:length encoding:NSASCIIStringEncoding freeWhenDone:YES]
  autorelease];
  }

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en


[twitter-dev] Re: iPhone::Incorrect oauth_signature for xAuth?

2010-09-13 Thread Nikolay Klimchuk
Still no luck

With your code I'm gettings exactly the same result
MUYmiobRdoK6s0ZVqo4xQNNO17w=

Something really strange in example here http://dev.twitter.com/pages/xauth

Nikolay Klimchuk

On Sep 13, 7:19 am, Tom van der Woerdt i...@tvdw.eu wrote:
 Oh, hehe, good point. That's because my Base String has one extra
 urlencoded '' on the end, and that shouldn't be there.

 Tom

 On Mon, 13 Sep 2010 04:18:06 -0700 (PDT), Nikolay Klimchuk



 klimc...@gmail.com wrote:
  Thank you Tom

  I will try your algorithm and compare results.
  Quick question: why you do this [str substringToIndex:[str
  length]-3] ?

  Nikolay Klimchuk

  On Sep 13, 2:46 am, Tom van der Woerdt i...@tvdw.eu wrote:
  Hi Nikolay,

  The first part of your code looks fine. You may, however, like to do
  some debugging on the HMAC part - it looks a bit too simple to me.

  This works :
          NSString *compKey = [NSString 
  stringWithFormat:@%@%@,secret,userSecret];
          const char *cKey = [compKey 
  cStringUsingEncoding:NSUTF8StringEncoding];
          const char *cData = [[str substringToIndex:[str length]-3]
  cStringUsingEncoding:NSUTF8StringEncoding];
          unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];
          CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData, strlen(cData), 
  cHMAC);
          NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC 
  length:sizeof(cHMAC)];
  (str being the Base String)

  Hope it helps :-)

  Tom

  On 9/13/10 3:02 AM, Nikolay Klimchuk wrote:

   I'm trying to understand why algorithm for calculation of
   oauth_signature does not give me the same result as shown here:
  http://dev.twitter.com/pages/xauth

   In my case I'm getting signedSK = 'MUYmiobRdoK6s0ZVqo4xQNNO17w='

   If I URL encode such result it's still very different from
   yUDBrcMMm6ghqBEKCFKVoJPIacU%3D

   I've tried different implementations, all of them give the same
   result. After few hours of exercises with all this stuff I completely
   run out of ideas, please help

   // Test with input data taken from Twitter page

   NSString *s= @POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
   %2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
   %26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
   %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
   %3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
   %26x_auth_password%3D%2525%2526123%2521aZ%252B
   %2528%2529456242134%26x_auth_username%3DtpFriendlyGiant;

   NSString *k = @5kEQypKe7lFHnufLtsocB1vAzO07xLFgp2Pc4sp2vk;

   NSString *signedSK = [NetworkManager base64forData:[NetworkManager
   HMACSHA1withKey:k forString:s]];

   // Source code

   + (NSData *)HMACSHA1withKey:(NSString *)key forString:(NSString
   *)string
   {
      NSData *clearTextData = [string
   dataUsingEncoding:NSUTF8StringEncoding];
      NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding];

      uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};

      CCHmacContext hmacContext;
      CCHmacInit(hmacContext, kCCHmacAlgSHA1, keyData.bytes,
   keyData.length);
      CCHmacUpdate(hmacContext, clearTextData.bytes,
   clearTextData.length);
      CCHmacFinal(hmacContext, digest);

      return [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
   }

   //Sourcehttp://www.cocoadev.com/index.pl?BaseSixtyFour

   + (NSString *)base64forData:(NSData *)data
   {
       static const char encodingTable[] =
   ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/;

       if ([data length] == 0)
           return @;

       char *characters = malloc((([data length] + 2) / 3) * 4);
       if (characters == NULL)
           return nil;
       NSUInteger length = 0;

       NSUInteger i = 0;
       while (i  [data length])
       {
           char buffer[3] = {0,0,0};
           short bufferLength = 0;
           while (bufferLength  3  i  [data length])
                      buffer[bufferLength++] = ((char *)[data bytes])[i++];

           //  Encode the bytes in the buffer to four characters,
   including padding = characters if necessary.
           characters[length++] = encodingTable[(buffer[0]  0xFC)  2];
           characters[length++] = encodingTable[((buffer[0]  0x03)  4)
   | ((buffer[1]  0xF0)  4)];
           if (bufferLength  1)
                      characters[length++] = encodingTable[((buffer[1]  
   0x0F)  2) |
   ((buffer[2]  0xC0)  6)];
           else characters[length++] = '=';
           if (bufferLength  2)
                      characters[length++] = encodingTable[buffer[2]  
   0x3F];
           else characters[length++] = '=';
       }

       return [[[NSString alloc] initWithBytesNoCopy:characters
   length:length encoding:NSASCIIStringEncoding freeWhenDone:YES]
   autorelease];
   }

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group

[twitter-dev] Re: XAuth signature error

2010-09-13 Thread Nikolay Klimchuk
What algorithm you're using for hmac-sha1 and base64

I'm getting different oauth_signature for the xAuth test example
http://dev.twitter.com/pages/xauth

Nikolay Klimchuk

On Sep 13, 1:01 am, Double K squel...@gmail.com wrote:
 hi, my name is Kim.
 I will make XAuth module. So i need developer help.
 i make signature base string
 for example

 POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
 %2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
 %26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
 %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
 %3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
 %26x_auth_password%3D%2525%2526123%2521aZ%252B
 %2528%2529456242134%26x_auth_username%3DtpFriendlyGiant

 this is dev.twitter.com example
 i saw it that oauth_signature is signature base string's hmac-sha1
 encoding and base64 encoding's result
 oauth_signature=yUDBrcMMm6ghqBEKCFKVoJPIacU%3D
 is it right?
 i can't do this.
 somebody help me. T.T

 Q1. i want to know signature base string's hmac-sha1 encoding result.
 Q2. oauth-signature=yUDBrcMMm6ghqBEKCFKVoJPIacU%3D is it correct?

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en


[twitter-dev] Re: iPhone::Incorrect oauth_signature for xAuth?

2010-09-14 Thread Nikolay Klimchuk
Can somebody recalculate test example from http://dev.twitter.com/pages/xauth
???

I'm looking for oauth_signature parameter

I'm getting different result and it does not make any sense so far

On Sep 13, 2:54 pm, Nikolay Klimchuk klimc...@gmail.com wrote:
 Thanks Tom

 I feel better now LoL

 On Sep 13, 2:41 pm, Tom van der Woerdt i...@tvdw.eu wrote:



  2010-09-13 20:39:11.190 Test[56513:207] NSData *HMAC: 3146268a 86d17682
  bab34655 aa8e3140 d34ed7bc
  2010-09-13 20:39:11.191 Test[56513:207] NSString *HMAC64:
  MUYmiobRdoK6s0ZVqo4xQNNO17w=

  Looks like you're right :-)

  @episod: You should fix that! :-)

  Tom

  On 9/13/10 8:23 PM, Nikolay Klimchuk wrote:

   Still no luck

   With your code I'm gettings exactly the same result
   MUYmiobRdoK6s0ZVqo4xQNNO17w=

   Something really strange in example herehttp://dev.twitter.com/pages/xauth

   Nikolay Klimchuk

   On Sep 13, 7:19 am, Tom van der Woerdt i...@tvdw.eu wrote:
   Oh, hehe, good point. That's because my Base String has one extra
   urlencoded '' on the end, and that shouldn't be there.

   Tom

   On Mon, 13 Sep 2010 04:18:06 -0700 (PDT), Nikolay Klimchuk

   klimc...@gmail.com wrote:
   Thank you Tom

   I will try your algorithm and compare results.
   Quick question: why you do this [str substringToIndex:[str
   length]-3] ?

   Nikolay Klimchuk

   On Sep 13, 2:46 am, Tom van der Woerdt i...@tvdw.eu wrote:
   Hi Nikolay,

   The first part of your code looks fine. You may, however, like to do
   some debugging on the HMAC part - it looks a bit too simple to me.

   This works :
           NSString *compKey = [NSString 
   stringWithFormat:@%@%@,secret,userSecret];
           const char *cKey = [compKey 
   cStringUsingEncoding:NSUTF8StringEncoding];
           const char *cData = [[str substringToIndex:[str length]-3]
   cStringUsingEncoding:NSUTF8StringEncoding];
           unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];
           CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData, 
   strlen(cData), cHMAC);
           NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC 
   length:sizeof(cHMAC)];
   (str being the Base String)

   Hope it helps :-)

   Tom

   On 9/13/10 3:02 AM, Nikolay Klimchuk wrote:

   I'm trying to understand why algorithm for calculation of
   oauth_signature does not give me the same result as shown here:
  http://dev.twitter.com/pages/xauth

   In my case I'm getting signedSK = 'MUYmiobRdoK6s0ZVqo4xQNNO17w='

   If I URL encode such result it's still very different from
   yUDBrcMMm6ghqBEKCFKVoJPIacU%3D

   I've tried different implementations, all of them give the same
   result. After few hours of exercises with all this stuff I completely
   run out of ideas, please help

   // Test with input data taken from Twitter page

   NSString *s= @POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
   %2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
   %26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
   %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
   %3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
   %26x_auth_password%3D%2525%2526123%2521aZ%252B
   %2528%2529456242134%26x_auth_username%3DtpFriendlyGiant;

   NSString *k = @5kEQypKe7lFHnufLtsocB1vAzO07xLFgp2Pc4sp2vk;

   NSString *signedSK = [NetworkManager base64forData:[NetworkManager
   HMACSHA1withKey:k forString:s]];

   // Source code

   + (NSData *)HMACSHA1withKey:(NSString *)key forString:(NSString
   *)string
   {
      NSData *clearTextData = [string
   dataUsingEncoding:NSUTF8StringEncoding];
      NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding];

      uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};

      CCHmacContext hmacContext;
      CCHmacInit(hmacContext, kCCHmacAlgSHA1, keyData.bytes,
   keyData.length);
      CCHmacUpdate(hmacContext, clearTextData.bytes,
   clearTextData.length);
      CCHmacFinal(hmacContext, digest);

      return [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
   }

   //Sourcehttp://www.cocoadev.com/index.pl?BaseSixtyFour

   + (NSString *)base64forData:(NSData *)data
   {
       static const char encodingTable[] =
   ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/;

       if ([data length] == 0)
           return @;

       char *characters = malloc((([data length] + 2) / 3) * 4);
       if (characters == NULL)
           return nil;
       NSUInteger length = 0;

       NSUInteger i = 0;
       while (i  [data length])
       {
           char buffer[3] = {0,0,0};
           short bufferLength = 0;
           while (bufferLength  3  i  [data length])
                      buffer[bufferLength++] = ((char *)[data 
   bytes])[i++];

           //  Encode the bytes in the buffer to four characters,
   including padding = characters if necessary.
           characters[length++] = encodingTable[(buffer[0]  0xFC)  2];
           characters[length++] = encodingTable[((buffer[0]  0x03)  4)
   | ((buffer[1]  0xF0)  4)];
           if (bufferLength  1

[twitter-dev] Re: iPhone::Incorrect oauth_signature for xAuth?

2010-09-15 Thread Nikolay Klimchuk
That's really puzzling for me. I've tried 5 different ways to get
oauth_signature, even extracted from libraries suggested by Twitter
All of them produce same result MUYmiobRdoK6s0ZVqo4xQNNO17w=
It's different from example http://dev.twitter.com/pages/xauth

I'm looking for any logical explanation for this

Nikolay Klimchuk

On Sep 15, 12:03 pm, Taylor Singletary taylorsinglet...@twitter.com
wrote:
 Hi Everyone,

 I've revised the xAuth examples athttp://dev.twitter.com/pages/xauth--
 you'll find they should have signatures that are easier to reproduce and was
 confirmed functional at the time of execution.

 Thanks for the nudge, Tom.

 Thanks,
 Taylor

 On Mon, Sep 13, 2010 at 11:41 AM, Tom van der Woerdt i...@tvdw.eu wrote:



  2010-09-13 20:39:11.190 Test[56513:207] NSData *HMAC: 3146268a 86d17682
  bab34655 aa8e3140 d34ed7bc
  2010-09-13 20:39:11.191 Test[56513:207] NSString *HMAC64:
  MUYmiobRdoK6s0ZVqo4xQNNO17w=

  Looks like you're right :-)

  @episod: You should fix that! :-)

  Tom

  On 9/13/10 8:23 PM, Nikolay Klimchuk wrote:
   Still no luck

   With your code I'm gettings exactly the same result
   MUYmiobRdoK6s0ZVqo4xQNNO17w=

   Something really strange in example here
 http://dev.twitter.com/pages/xauth

   Nikolay Klimchuk

   On Sep 13, 7:19 am, Tom van der Woerdt i...@tvdw.eu wrote:
   Oh, hehe, good point. That's because my Base String has one extra
   urlencoded '' on the end, and that shouldn't be there.

   Tom

   On Mon, 13 Sep 2010 04:18:06 -0700 (PDT), Nikolay Klimchuk

   klimc...@gmail.com wrote:
   Thank you Tom

   I will try your algorithm and compare results.
   Quick question: why you do this [str substringToIndex:[str
   length]-3] ?

   Nikolay Klimchuk

   On Sep 13, 2:46 am, Tom van der Woerdt i...@tvdw.eu wrote:
   Hi Nikolay,

   The first part of your code looks fine. You may, however, like to do
   some debugging on the HMAC part - it looks a bit too simple to me.

   This works :
           NSString *compKey = [NSString stringWithFormat:@
  %@%@,secret,userSecret];
           const char *cKey = [compKey
  cStringUsingEncoding:NSUTF8StringEncoding];
           const char *cData = [[str substringToIndex:[str length]-3]
   cStringUsingEncoding:NSUTF8StringEncoding];
           unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];
           CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData,
  strlen(cData), cHMAC);
           NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC
  length:sizeof(cHMAC)];
   (str being the Base String)

   Hope it helps :-)

   Tom

   On 9/13/10 3:02 AM, Nikolay Klimchuk wrote:

   I'm trying to understand why algorithm for calculation of
   oauth_signature does not give me the same result as shown here:
  http://dev.twitter.com/pages/xauth

   In my case I'm getting signedSK = 'MUYmiobRdoK6s0ZVqo4xQNNO17w='

   If I URL encode such result it's still very different from
   yUDBrcMMm6ghqBEKCFKVoJPIacU%3D

   I've tried different implementations, all of them give the same
   result. After few hours of exercises with all this stuff I completely
   run out of ideas, please help

   // Test with input data taken from Twitter page

   NSString *s= @POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
   %2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
   %26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
   %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
   %3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
   %26x_auth_password%3D%2525%2526123%2521aZ%252B
   %2528%2529456242134%26x_auth_username%3DtpFriendlyGiant;

   NSString *k = @5kEQypKe7lFHnufLtsocB1vAzO07xLFgp2Pc4sp2vk;

   NSString *signedSK = [NetworkManager base64forData:[NetworkManager
   HMACSHA1withKey:k forString:s]];

   // Source code

   + (NSData *)HMACSHA1withKey:(NSString *)key forString:(NSString
   *)string
   {
      NSData *clearTextData = [string
   dataUsingEncoding:NSUTF8StringEncoding];
      NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding];

      uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};

      CCHmacContext hmacContext;
      CCHmacInit(hmacContext, kCCHmacAlgSHA1, keyData.bytes,
   keyData.length);
      CCHmacUpdate(hmacContext, clearTextData.bytes,
   clearTextData.length);
      CCHmacFinal(hmacContext, digest);

      return [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
   }

   //Sourcehttp://www.cocoadev.com/index.pl?BaseSixtyFour

   + (NSString *)base64forData:(NSData *)data
   {
       static const char encodingTable[] =
   ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/;

       if ([data length] == 0)
           return @;

       char *characters = malloc((([data length] + 2) / 3) * 4);
       if (characters == NULL)
           return nil;
       NSUInteger length = 0;

       NSUInteger i = 0;
       while (i  [data length])
       {
           char buffer[3] = {0,0,0};
           short bufferLength = 0;
           while (bufferLength  3  i  [data length

[twitter-dev] Re: iPhone::Incorrect oauth_signature for xAuth?

2010-09-16 Thread Nikolay Klimchuk
The code I've used is in the first message of this topic

On Sep 16, 12:21 pm, Taylor Singletary taylorsinglet...@twitter.com
wrote:
 Can you share the code you're using?

 On Wed, Sep 15, 2010 at 8:02 PM, Nikolay Klimchuk klimc...@gmail.comwrote:



  That's really puzzling for me. I've tried 5 different ways to get
  oauth_signature, even extracted from libraries suggested by Twitter
  All of them produce same result MUYmiobRdoK6s0ZVqo4xQNNO17w=
  It's different from examplehttp://dev.twitter.com/pages/xauth

  I'm looking for any logical explanation for this

  Nikolay Klimchuk

  On Sep 15, 12:03 pm, Taylor Singletary taylorsinglet...@twitter.com
  wrote:
   Hi Everyone,

   I've revised the xAuth examples athttp://dev.twitter.com/pages/xauth--
   you'll find they should have signatures that are easier to reproduce and
  was
   confirmed functional at the time of execution.

   Thanks for the nudge, Tom.

   Thanks,
   Taylor

   On Mon, Sep 13, 2010 at 11:41 AM, Tom van der Woerdt i...@tvdw.eu
  wrote:

2010-09-13 20:39:11.190 Test[56513:207] NSData *HMAC: 3146268a
  86d17682
bab34655 aa8e3140 d34ed7bc
2010-09-13 20:39:11.191 Test[56513:207] NSString *HMAC64:
MUYmiobRdoK6s0ZVqo4xQNNO17w=

Looks like you're right :-)

@episod: You should fix that! :-)

Tom

On 9/13/10 8:23 PM, Nikolay Klimchuk wrote:
 Still no luck

 With your code I'm gettings exactly the same result
 MUYmiobRdoK6s0ZVqo4xQNNO17w=

 Something really strange in example here
   http://dev.twitter.com/pages/xauth

 Nikolay Klimchuk

 On Sep 13, 7:19 am, Tom van der Woerdt i...@tvdw.eu wrote:
 Oh, hehe, good point. That's because my Base String has one extra
 urlencoded '' on the end, and that shouldn't be there.

 Tom

 On Mon, 13 Sep 2010 04:18:06 -0700 (PDT), Nikolay Klimchuk

 klimc...@gmail.com wrote:
 Thank you Tom

 I will try your algorithm and compare results.
 Quick question: why you do this [str substringToIndex:[str
 length]-3] ?

 Nikolay Klimchuk

 On Sep 13, 2:46 am, Tom van der Woerdt i...@tvdw.eu wrote:
 Hi Nikolay,

 The first part of your code looks fine. You may, however, like to
  do
 some debugging on the HMAC part - it looks a bit too simple to me.

 This works :
         NSString *compKey = [NSString stringWithFormat:@
%@%@,secret,userSecret];
         const char *cKey = [compKey
cStringUsingEncoding:NSUTF8StringEncoding];
         const char *cData = [[str substringToIndex:[str length]-3]
 cStringUsingEncoding:NSUTF8StringEncoding];
         unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];
         CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData,
strlen(cData), cHMAC);
         NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC
length:sizeof(cHMAC)];
 (str being the Base String)

 Hope it helps :-)

 Tom

 On 9/13/10 3:02 AM, Nikolay Klimchuk wrote:

 I'm trying to understand why algorithm for calculation of
 oauth_signature does not give me the same result as shown here:
http://dev.twitter.com/pages/xauth

 In my case I'm getting signedSK = 'MUYmiobRdoK6s0ZVqo4xQNNO17w='

 If I URL encode such result it's still very different from
 yUDBrcMMm6ghqBEKCFKVoJPIacU%3D

 I've tried different implementations, all of them give the same
 result. After few hours of exercises with all this stuff I
  completely
 run out of ideas, please help

 // Test with input data taken from Twitter page

 NSString *s= @POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
 %2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
 %26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
 %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
 %3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
 %26x_auth_password%3D%2525%2526123%2521aZ%252B
 %2528%2529456242134%26x_auth_username%3DtpFriendlyGiant;

 NSString *k = @5kEQypKe7lFHnufLtsocB1vAzO07xLFgp2Pc4sp2vk;

 NSString *signedSK = [NetworkManager
  base64forData:[NetworkManager
 HMACSHA1withKey:k forString:s]];

 // Source code

 + (NSData *)HMACSHA1withKey:(NSString *)key forString:(NSString
 *)string
 {
    NSData *clearTextData = [string
 dataUsingEncoding:NSUTF8StringEncoding];
    NSData *keyData = [key
  dataUsingEncoding:NSUTF8StringEncoding];

    uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};

    CCHmacContext hmacContext;
    CCHmacInit(hmacContext, kCCHmacAlgSHA1, keyData.bytes,
 keyData.length);
    CCHmacUpdate(hmacContext, clearTextData.bytes,
 clearTextData.length);
    CCHmacFinal(hmacContext, digest);

    return [NSData dataWithBytes:digest
  length:CC_SHA1_DIGEST_LENGTH];
 }

 //Sourcehttp://www.cocoadev.com/index.pl?BaseSixtyFour

 + (NSString *)base64forData:(NSData *)data
 {
     static const char encodingTable

[twitter-dev] Re: Failed to validate oauth signature and token with xAuth

2010-09-18 Thread Nikolay Klimchuk
Second part of the base string:
oauth_consumer_key=sGNxxnqgZRHUt6NunK3uwoauth_nonce=WLxsob
j4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hAoauth_signature_method=HMAC-
SHA1oauth_timestamp=1276101652oauth_version=1.0x_auth_mode=client_authx
_auth_password=
%25123!aZ+()456242134x_auth_username=tpFriendlyGiant

Should be also URLEncoded

On Sep 18, 7:19 am, mlowicki mlowi...@gmail.com wrote:
 I tried with data fromhttp://dev.twitter.com/pages/xauth:

 (function() {
 var secret = 5kEQypKe7lFHnufLtsocB1vAzO07xLFgp2Pc4sp2vk;
 var access_token = oauth_consumer_key=sGNxxnqgZRHUt6NunK3uw +
 oauth_nonce=WLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA +
 oauth_signature_method=HMAC-SHA1 +
 oauth_timestamp=1276101652 +
 oauth_version=1.0 +
 x_auth_mode=client_auth +
 x_auth_password=%123!aZ+()456242134 +
 x_auth_username=tpFriendlyGiant;
 var base_string = POST +
 encodeURIComponent(
 https://api.twitter.com/oauth/access_token;) +  +
 encodeURIComponent(access_token);

 console.debug(base_string, base_string);
 console.debug(oauth_signature, b64_hmac_sha1(secret, base_string));

 })();

 This is my base_string:

 POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
 %2Faccess_tokenoauth_consumer_key=sGNxxnqgZRHUt6NunK3uwoauth_nonce=WLxsob 
 j4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hAoauth_signature_method=HMAC-
 SHA1oauth_timestamp=1276101652oauth_version=1.0x_auth_mode=client_authx 
 _auth_password=
 %25123!aZ+()456242134x_auth_username=tpFriendlyGiant

 This on is from dev.twitter.com

 POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
 %2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
 %26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
 %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
 %3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
 %26x_auth_password%3D%2525%2526123%2521aZ%252B
 %2528%2529456242134%26x_auth_username%3DtpFriendlyGiant

 I found the differences in encoding %123!aZ+() prefix from password
 in base_string:

 From dev.twitter.com/pages/xauth:

 %2525%2526123%2521aZ%252B%2528%2529

 From code above:

 %25%26123!aZ%2B()

 I use wrong encoding method then and encoding is wrong applied?

 BR,
 Michał Łowicki

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en


[twitter-dev] Re: Failed to validate oauth signature and token with xAuth

2010-09-18 Thread Nikolay Klimchuk
You need to URLEndcode password and user name
And then URLEncode entire base string one more time

On Sep 18, 5:55 pm, Tom van der Woerdt i...@tvdw.eu wrote:
 Nikolay,

 If you look at the code, you'll see that it's already passed through the URL 
 encode function, but it doesn't do a thing. I'd say that the issue is at that 
 function.

 Tom

 On Sep 18, 2010, at 11:41 PM, Nikolay Klimchuk klimc...@gmail.com wrote:



  Second part of the base string:
  oauth_consumer_key=sGNxxnqgZRHUt6NunK3uwoauth_nonce=WLxsob
  j4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hAoauth_signature_method=HMAC-
  SHA1oauth_timestamp=1276101652oauth_version=1.0x_auth_mode=client_authx
  _auth_password=
  %25123!aZ+()456242134x_auth_username=tpFriendlyGiant

  Should be also URLEncoded

  On Sep 18, 7:19 am, mlowicki mlowi...@gmail.com wrote:
  I tried with data fromhttp://dev.twitter.com/pages/xauth:

  (function() {
  var secret = 5kEQypKe7lFHnufLtsocB1vAzO07xLFgp2Pc4sp2vk;
  var access_token = oauth_consumer_key=sGNxxnqgZRHUt6NunK3uw +
  oauth_nonce=WLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA +
  oauth_signature_method=HMAC-SHA1 +
  oauth_timestamp=1276101652 +
  oauth_version=1.0 +
  x_auth_mode=client_auth +
  x_auth_password=%123!aZ+()456242134 +
  x_auth_username=tpFriendlyGiant;
  var base_string = POST +
  encodeURIComponent(
  https://api.twitter.com/oauth/access_token;) +  +
  encodeURIComponent(access_token);

  console.debug(base_string, base_string);
  console.debug(oauth_signature, b64_hmac_sha1(secret, base_string));

  })();

  This is my base_string:

  POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
  %2Faccess_tokenoauth_consumer_key=sGNxxnqgZRHUt6NunK3uwoauth_nonce=WLxsob
   j4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hAoauth_signature_method=HMAC-
  SHA1oauth_timestamp=1276101652oauth_version=1.0x_auth_mode=client_authx
   _auth_password=
  %25123!aZ+()456242134x_auth_username=tpFriendlyGiant

  This on is from dev.twitter.com

  POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
  %2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
  %26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
  %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
  %3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
  %26x_auth_password%3D%2525%2526123%2521aZ%252B
  %2528%2529456242134%26x_auth_username%3DtpFriendlyGiant

  I found the differences in encoding %123!aZ+() prefix from password
  in base_string:

  From dev.twitter.com/pages/xauth:

  %2525%2526123%2521aZ%252B%2528%2529

  From code above:

  %25%26123!aZ%2B()

  I use wrong encoding method then and encoding is wrong applied?

  BR,
  Michał Łowicki

  --
  Twitter developer documentation and resources:http://dev.twitter.com/doc
  API updates via Twitter:http://twitter.com/twitterapi
  Issues/Enhancements Tracker:http://code.google.com/p/twitter-api/issues/list
  Change your membership to this 
  group:http://groups.google.com/group/twitter-development-talk?hl=en

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en


[twitter-dev] Re: iPhone::Incorrect oauth_signature for xAuth?

2010-09-19 Thread Nikolay Klimchuk
Good news everyone

Twitter changed example at http://dev.twitter.com/pages/xauth
Now my code gives the same result as in example

NSString *s= @POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
%2Faccess_tokenoauth_consumer_key%3DJvyS7DO2qd6NNTsXJ4E7zA
%26oauth_nonce%3D6AN2dKRzxyGhmIXUKSmp1JcB4pckM8rD3frKMTmVAo
%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
%3D1284565601%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
%26x_auth_password%3Dtwitter-xauth%26x_auth_username
%3Doauth_test_exec;
NSString *k = @9z6157pUbOBqtbm0A0q4r29Y2EYzIHlUwbF4Cl9c;

Gives oauth_signature=1L1oXQmawZAkQ47FHLwcOV%2Bkjwc%3D

On Sep 16, 12:21 pm, Taylor Singletary taylorsinglet...@twitter.com
wrote:
 Can you share the code you're using?

 On Wed, Sep 15, 2010 at 8:02 PM, Nikolay Klimchuk klimc...@gmail.comwrote:



  That's really puzzling for me. I've tried 5 different ways to get
  oauth_signature, even extracted from libraries suggested by Twitter
  All of them produce same result MUYmiobRdoK6s0ZVqo4xQNNO17w=
  It's different from examplehttp://dev.twitter.com/pages/xauth

  I'm looking for any logical explanation for this

  Nikolay Klimchuk

  On Sep 15, 12:03 pm, Taylor Singletary taylorsinglet...@twitter.com
  wrote:
   Hi Everyone,

   I've revised the xAuth examples athttp://dev.twitter.com/pages/xauth--
   you'll find they should have signatures that are easier to reproduce and
  was
   confirmed functional at the time of execution.

   Thanks for the nudge, Tom.

   Thanks,
   Taylor

   On Mon, Sep 13, 2010 at 11:41 AM, Tom van der Woerdt i...@tvdw.eu
  wrote:

2010-09-13 20:39:11.190 Test[56513:207] NSData *HMAC: 3146268a
  86d17682
bab34655 aa8e3140 d34ed7bc
2010-09-13 20:39:11.191 Test[56513:207] NSString *HMAC64:
MUYmiobRdoK6s0ZVqo4xQNNO17w=

Looks like you're right :-)

@episod: You should fix that! :-)

Tom

On 9/13/10 8:23 PM, Nikolay Klimchuk wrote:
 Still no luck

 With your code I'm gettings exactly the same result
 MUYmiobRdoK6s0ZVqo4xQNNO17w=

 Something really strange in example here
   http://dev.twitter.com/pages/xauth

 Nikolay Klimchuk

 On Sep 13, 7:19 am, Tom van der Woerdt i...@tvdw.eu wrote:
 Oh, hehe, good point. That's because my Base String has one extra
 urlencoded '' on the end, and that shouldn't be there.

 Tom

 On Mon, 13 Sep 2010 04:18:06 -0700 (PDT), Nikolay Klimchuk

 klimc...@gmail.com wrote:
 Thank you Tom

 I will try your algorithm and compare results.
 Quick question: why you do this [str substringToIndex:[str
 length]-3] ?

 Nikolay Klimchuk

 On Sep 13, 2:46 am, Tom van der Woerdt i...@tvdw.eu wrote:
 Hi Nikolay,

 The first part of your code looks fine. You may, however, like to
  do
 some debugging on the HMAC part - it looks a bit too simple to me.

 This works :
         NSString *compKey = [NSString stringWithFormat:@
%@%@,secret,userSecret];
         const char *cKey = [compKey
cStringUsingEncoding:NSUTF8StringEncoding];
         const char *cData = [[str substringToIndex:[str length]-3]
 cStringUsingEncoding:NSUTF8StringEncoding];
         unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];
         CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData,
strlen(cData), cHMAC);
         NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC
length:sizeof(cHMAC)];
 (str being the Base String)

 Hope it helps :-)

 Tom

 On 9/13/10 3:02 AM, Nikolay Klimchuk wrote:

 I'm trying to understand why algorithm for calculation of
 oauth_signature does not give me the same result as shown here:
http://dev.twitter.com/pages/xauth

 In my case I'm getting signedSK = 'MUYmiobRdoK6s0ZVqo4xQNNO17w='

 If I URL encode such result it's still very different from
 yUDBrcMMm6ghqBEKCFKVoJPIacU%3D

 I've tried different implementations, all of them give the same
 result. After few hours of exercises with all this stuff I
  completely
 run out of ideas, please help

 // Test with input data taken from Twitter page

 NSString *s= @POSThttps%3A%2F%2Fapi.twitter.com%2Foauth
 %2Faccess_tokenoauth_consumer_key%3DsGNxxnqgZRHUt6NunK3uw
 %26oauth_nonce%3DWLxsobj4rhS2xmCbaAeT4aAkRfx4vSHX4OnYpTE77hA
 %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
 %3D1276101652%26oauth_version%3D1.0%26x_auth_mode%3Dclient_auth
 %26x_auth_password%3D%2525%2526123%2521aZ%252B
 %2528%2529456242134%26x_auth_username%3DtpFriendlyGiant;

 NSString *k = @5kEQypKe7lFHnufLtsocB1vAzO07xLFgp2Pc4sp2vk;

 NSString *signedSK = [NetworkManager
  base64forData:[NetworkManager
 HMACSHA1withKey:k forString:s]];

 // Source code

 + (NSData *)HMACSHA1withKey:(NSString *)key forString:(NSString
 *)string
 {
    NSData *clearTextData = [string
 dataUsingEncoding:NSUTF8StringEncoding];
    NSData *keyData = [key
  dataUsingEncoding:NSUTF8StringEncoding

[twitter-dev] Re: “Failed to validate oauth signat ure and token

2010-09-19 Thread Nikolay Klimchuk
Sorry I don't know answer on your question but in general would be
nice to have more informative error messages from Twitter

I'm tired of Failed to validate oauth signature and token, if there is
a problem with timestamp just let me know!

It will also reduce amount of messages in this group

On Sep 19, 11:39 am, bill ramesh.billap...@gmail.com wrote:
 Hi,

 I am trying a do twitter authentication using oAuth. I am getting
 error in first step itself (i.e while getting RequestToken itself). I
 am trying this from a php page running on my machin (twitter
 application registered as desktop application). I am new to php
 development, any inputs are appreciated. Below are Request and
 Response

 Thanks,
 Ramesh

 --
 request
 --

 HTTP_OAuth_Consumer_Request Object ( [authType:protected] = 1
 [secrets:protected] = Array ( [0] =
 Cxnk2e8Kbz8CLskAwzl7BBlCvkjPptSHcEIzXXvUAE [1] = )
 [request:protected] = HTTP_Request2 Object ( [observers:protected] =
 Array ( ) [url:protected] = Net_URL2 Object
 ( [_options:Net_URL2:private] = Array ( [strict] = 1 [use_brackets]
 = 1 [encode_keys] = 1 [input_separator] =  [output_separator] =
  ) [_scheme:Net_URL2:private] = http [_userinfo:Net_URL2:private] =
 [_host:Net_URL2:private] = twitter.com [_port:Net_URL2:private] =
 [_path:Net_URL2:private] = /oauth/request_token
 [_query:Net_URL2:private] = [_fragment:Net_URL2:private] = )
 [method:protected] = POST [auth:protected] = [headers:protected] =
 Array ( [user-agent] = HTTP_Request2/0.5.2 (http://pear.php.net/
 package/http_request2) PHP/5.3.1 [authorization] = OAuth
 realm=http://twitter.com/;,
 oauth_consumer_key=*,
 oauth_nonce=*,
 oauth_signature=*, oauth_signature_method=HMAC-
 SHA1, oauth_timestamp=1284910240, oauth_version=1.0 )
 [config:protected] = Array ( [adapter] =
 HTTP_Request2_Adapter_Socket [connect_timeout] = 10 [timeout] = 0
 [use_brackets] = 1 [protocol_version] = 1.1 [buffer_size] = 16384
 [store_body] = 1 [proxy_host] = [proxy_port] = [proxy_user] =
 [proxy_password] = [proxy_auth_scheme] = basic [ssl_verify_peer] =
 1 [ssl_verify_host] = 1 [ssl_cafile] = [ssl_capath] =
 [ssl_local_cert] = [ssl_passphrase] = [digest_compat_ie] =
 [follow_redirects] = [max_redirects] = 5 [strict_redirects] = )
 [lastEvent:protected] = Array ( [name] = disconnect [data] = )
 [body:protected] = [postParams:protected] = Array ( )
 [uploads:protected] = Array ( ) [adapter:protected] =
 HTTP_Request2_Adapter_Socket Object ( [serverChallenge:protected] =
 [proxyChallenge:protected] = [deadline:protected] =
 [chunkLength:protected] = 0 [redirectCountdown:protected] =
 [contentLength:protected] = 0 [socket:protected] = ) )
 [parameters:protected] = Array ( [oauth_callback] =
 [oauth_consumer_key] = * [oauth_signature_method]
 = HMAC-SHA1 [oauth_timestamp] = 1284910240 [oauth_nonce] =
 * [oauth_version] = 1.0 [oauth_signature] =
 = ) )
 --
 response
 --

 HTTP_OAuth_Consumer_Response Object ( [response:protected] =
 HTTP_Request2_Response Object ( [version:protected] = 1.1
 [code:protected] = 401 [reasonPhrase:protected] = Unauthorized
 [headers:protected] = Array ( [date] = Sun, 19 Sep 2010 15:30:41 GMT
 [server] = hi [status] = 401 Unauthorized [x-transaction] =
 1284910241-69054-62865 [last-modified] = Sun, 19 Sep 2010 15:30:41
 GMT [x-runtime] = 0.01374 [content-type] = text/html; charset=utf-8
 [pragma] = no-cache [x-revision] = DEV [expires] = Tue, 31 Mar 1981
 05:00:00 GMT [cache-control] = no-cache, no-store, must-revalidate,
 pre-check=0, post-check=0 [x-xss-protection] = 1; mode=block [x-frame-
 options] = SAMEORIGIN [vary] = Accept-Encoding [content-encoding] =
 gzip [content-length] = 62 [connection] = close )
 [cookies:protected] = Array ( [0] = Array ( [expires] = Sun, 26-
 Sep-10 15:30:41 GMT [domain] = .twitter.com [path] = / [secure] =
 [name] = k [value] = 98.180.203.164.1284910241513942 ) [1] = Array
 ( [expires] = Tue, 19 Oct 2010 15:30:41 GMT [domain] = [path] = /
 [secure] = [name] = guest_id [value] = 128491024151857994 ) [2] =
 Array ( [expires] = [domain] = .twitter.com [path] = / [secure] =
 [name] = _twitter_sess [value] =
 **d2f0b79c14dec4c9fe0ac026395fd6afc 
 68a3c75 ) )
 [lastHeader:protected] = connection [body:protected] =
  ‹  sKÌÌIMQ(ÉW(KÌÉLI,IUÈO,-ÉP(ÎLÏK,)-JUHÌ Ég§æ  šÎë,
 [bodyEncoded:protected] = 1 ) [parameters:protected] = Array ( ) )
 ERROR: Failed getting token and token secret from response

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en