title: Making a GET call on an OAuth protected URL, part 2
body: <p>I've been trying to get a basic OAuth interaction working without success. There are certainly similar questions already posed on SO, but most of them have no replies. I'm getting pretty desperate here, so I'm just going to start by posting my entire code:</p>
  
  <pre><code>// OAuth parameters
  NSString *oauthNonce = [self genRandStringLength:20];
  NSString *oauthSignatureMethod = [NSString stringWithFormat:@"HMAC-SHA1"];
  time_t oauthTimeStamp = (time_t) [[NSDate date] timeIntervalSince1970];
  
  // generate OAuth signature
  NSString *encodedUrlString = [self urlEncode:urlString];
  
  NSString *oauthParameters = [NSString stringWithFormat:@"oauth_consumer_key=%@",oauthConsumerKey];
  oauthParameters = [oauthParameters stringByAppendingFormat:@"&amp;oauth_nonce=%@",oauthNonce];
  oauthParameters = [oauthParameters stringByAppendingFormat:@"&amp;oauth_signature_method=%@",oauthSignatureMethod];
  oauthParameters = [oauthParameters stringByAppendingFormat:@"&amp;oauth_timestamp=%d",oauthTimeStamp];
  oauthParameters = [oauthParameters stringByAppendingFormat:@"&amp;oauth_token=%@",oauthAccessToken];
  oauthParameters = [oauthParameters stringByAppendingFormat:@"&amp;oauth_version=1.0"];
  NSString *oauthEncodedParameters = [self urlEncode:oauthParameters];
  
  NSString *oauthBaseString = [NSString stringWithFormat:@"GET&amp;%@&amp;%@",encodedUrlString,oauthEncodedParameters];
  
  NSString *oauthKey = [NSString stringWithFormat:@"%@&amp;%@", oauthConsumerSecret, oauthAccessTokenSecret];
  NSString *oauthEncodedKey = [self urlEncode:oauthKey];
  
  OAHMAC_SHA1SignatureProvider *provider = [[OAHMAC_SHA1SignatureProvider alloc] init];
  NSString *oauthSignature = [provider signClearText:oauthBaseString withSecret:oauthEncodedKey];
  NSString *oauthEncodedSignature = [self urlEncode:oauthSignature];
  
  // prepare request
  NSString *oauthHeader = @"OAuth ";
  oauthHeader = [oauthHeader stringByAppendingFormat:@"oauth_consumer_key=\"%@\"",oauthConsumerKey];
  oauthHeader = [oauthHeader stringByAppendingFormat:@",oauth_token=\"%@\"",oauthAccessToken];
  oauthHeader = [oauthHeader stringByAppendingFormat:@",oauth_signature_method=\"%@\"",oauthSignatureMethod];
  oauthHeader = [oauthHeader stringByAppendingFormat:@",oauth_signature=\"%@\"",oauthEncodedSignature];
  oauthHeader = [oauthHeader stringByAppendingFormat:@",oauth_timestamp=\"%d\"",oauthTimeStamp];
  oauthHeader = [oauthHeader stringByAppendingFormat:@",oauth_nonce=\"%@\"",oauthNonce];
  oauthHeader = [oauthHeader stringByAppendingFormat:@",oauth_version=\"1.0\""];
  
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]];
  [request setHTTPMethod:@"GET"];
  [request setValue:oauthHeader forHTTPHeaderField:@"Authorization"];
  
  NSHTTPURLResponse *response = nil;
  NSError *error = nil;
  NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
  </code></pre>
  
  <p>When I look at the http response code I get a 500. I've reached out to the service provider regarding the unexpected 500 response.</p>
  
  <p>In the meanwhile, does anything stand out to you on what I'm possibly doing wrong?</p>
  
  <p>Even just pointing me to some working sample code would be highly appreciated. I've read a lot of stuff out there, but I'm obviously getting some nuance wrong in obj-c. Thanks in advance.</p>