title: iPhone Objective C oauth 2.0 Login - unsupported_grant_type
body: <p>I am brand new to salesforce development and am trying to connect to Salesforce to get the token.</p>
  
  <p>I guess my question is 2 fold: 
  1) Do I have to use a webpage to authenticate with SF?</p>
  
  <p>2) If not, why is this not working?  When I try to use the username and password method of authenticating, I get:
  {"error":"unsupported_grant_type","error_description":"grant type not supported"}</p>
  
  <p>Here is my code: </p>
  
  <pre><code>NSString *post = [NSString stringWithFormat:@"grant_type=basic-credentials&amp;client_id=%@&amp;client_secret=%@&amp;redirect_uri=%@",
                    kOAuthClientID,
                    kOAuthClientSecret,
                    kOAuthClientAuthURL
                    ];
  
  
  NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
  NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
  
  NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
  [request setURL:[NSURL URLWithString:kOAuthClientTokenUrl]];
  [request setHTTPMethod:@"POST"];
  [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
  [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
  [request setHTTPBody:postData];
  
  NSError *error;
  NSURLResponse *response;
  NSLog(@"%@", request);
  NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
  NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
  NSLog(@"%@", data);
  </code></pre>
  
  <p>Any thoughts would be welcome.</p>
  
  <p>I did try using grant_type = authorization_code but got another error: </p>
  
  <blockquote>
    <p>{"error":"invalid_grant","error_description":"invalid authorization
    code"}</p>
  </blockquote>