function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gshuflingshuflin 

accessing salesforce page from iOS with standard cocoa tools

I'm using the salesforce iOS toolkit (http://wiki.developerforce.com/index.php/Force.com_Toolkit_for_iOS) in writing a custom iPad app, using oAuth authentication. This is working fine for making SOQL queries, but I need to be able to access certain salesforce pages that require authentication in a browser. I want to use the standard cocoa URL tools (ex. NSString initWithContentsOfURL) to request the source code of the salesforce pages I need, but every time I try salesforce responds to the request with the login page, and I end up with the HTML for the login page rather than the HTML for the page I'm trying to access. How do I make a web request to salesforce using the authentication information I have from the iOS toolkit's oAuth implementation?

SuperfellSuperfell

You can't, the access token returned from the oauth flow is only valid for API calls, not for accessing any of the UI.

gshuflingshuflin

Huh, well that's an annoyance. Mostly what I'm trying to do is make this http request without user input. If I made a dummy salesforce account for precisely the purpose of accessing this one page (with appropriate permissions set), I suppose I could hard-code the username and password and authenticate the HTTP request with those, separate from the oAuth authentication for the API requests. How would I build an HTTP request that would return a page from within iOS, assuming I can hard code the username/password/security token?

SuperfellSuperfell

I'd start by explaining why you're trying to screenscrape a UI page, rather than fetch data via the API.

gshuflingshuflin

See http://boards.developerforce.com/t5/Apex-Code-Development/Getting-SOQL-equivalent-of-a-user-generated-report/m-p/320701#M56825 And yeah, scraping a salesforce page isn't an ideal solution, I just can't see any other way of implementing the functionality I need. If there's some API-based method of getting the particular records in a user-generated report programatically, I'd love to use that.