title: Instagram API giving "Invalid platform app" error when I am trying to fetch the access token
body: <p>I am trying to fetch the access token using this API: <a href="https://api.instagram.com/oauth/access_token" rel="nofollow noreferrer">https://api.instagram.com/oauth/access_token</a>. I have made sure to use the instagram app ID only and have also taken care of the content type to be "x-www-form-urlencoded" as suggested in the following answers: <a href="https://stackoverflow.com/questions/58488911/authenticate-the-test-user-error-type-oauthexception-code-400-error">Authenticate the Test User { &quot;error_type&quot;: &quot;OAuthException&quot;, &quot;code&quot;: 400, &quot;error_message&quot;: &quot;Invalid platform app&quot; }</a>. The API works perfectly fine in postman though but gives the following error response through my code: </p>
  
  <p>{"error_type": "OAuthException", "code": 400, "error_message": "Invalid platform app"}</p>
  
  <p>Here is my peice of code:</p>
  
  <pre><code>-(void)fetchAccessTokenForInsta{
  
  NSString *targetUrl = [NSString stringWithFormat:@"%@", @"https://api.instagram.com/oauth/access_token"];
  NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
  
  NSDictionary *tmp = @{@"client_id":@"126.....", @"client_secret":@"c79c.....", @"grant_type":@"authorization_code", @"redirect_uri":@"https://firebase.google.com/", @"code":_codeStr};
  NSError *error;
  NSData *postData = [NSJSONSerialization dataWithJSONObject:tmp options:0 error:&amp;error];
  
  [request setHTTPBody:postData];
  [request setHTTPMethod:@"POST"];
  [request setURL:[NSURL URLWithString:targetUrl]];
  
  NSDictionary *headers = @{@"Content-Type": @"application/x-www-form-urlencoded" };
  [request setAllHTTPHeaderFields:headers];
  
  [[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:
    ^(NSData * _Nullable data,
      NSURLResponse * _Nullable response,
      NSError * _Nullable error) {
  
        NSString *responseStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"Data received: %@", responseStr);
  }] resume];
  }
  </code></pre>
  
  <p>Where _codeStr is the string after removing # from the code received in the earlier step. Any help is appreciated.</p>