title: NSURLConnection Authorization Header not Working
body: <p>I am trying to send an OAuth access token in an HTTP header via NSURLConnection but it doesn't seem to be sending the header because the API keeps giving me an error saying that "must provide authorization token".</p>
  
  <p>This is the code that I am using:</p>
  
  <pre><code>NSURL *aUrl = [NSURL URLWithString: @"http://generericfakeapi.com/user/profile"];
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aUrl
                                                         cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                     timeoutInterval:30.0];
  
  [request addValue:[NSString stringWithFormat:@"OAuth %@", token] forHTTPHeaderField:@"Authorization"];
  
  [request setHTTPMethod:@"GET"];
  
  NSError *error = nil;
  NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error: &amp;error];
  
  NSDictionary *JSONDictionary = [NSJSONSerialization JSONObjectWithData:returnData options:kNilOptions error:&amp;error];
  NSLog(@"Response : %@", JSONDictionary);
  </code></pre>
  
  <p>And this is an example of the cURL command for the API:</p>
  
  <pre><code>curl 'http://generericfakeapi.com/user/profile' -H 'Authorization: OAuth YourAuthToken'
  </code></pre>
  
  <p>Is this not what I am essentially doing through NSURLConnection?</p>
  
  <p>Any help would be appreciated.</p>