SalesForce on iOS login without using the SalesForce Webview? - iphone

I'm creating an iPhone application that uses salesforce as it's server-side data component, I need to access the database from the application to retrieve data for whichever user logs into the app, to do this I need to authenticate with Sales force.
I'm using the Rest API Template that was available in XCode after installing SalesForce, but I keep getting this:
Is there any way I can login to salesforce programmatically? I'd like our use of Salesforce to be 'behind the scenes' so to speak, so that our users never have to directly interact with salesforce themselves, is there any way to do this?

That looks like the OAuth challenge. You should be able to bypass this by providing a Session Id. In order to get a Session ID, you have to login with the user's username and password. You can use the SOAP API for this.

Yes you can do the login behind the scenes.
Follow this Self login in Salesforce API in iPhone?
I was stuck with the same issue and finally figured it out.

Related

How I can auto login with SwiftyDropbox?

I have an app with SwiftyDropbox that function correctly, but I need to insert email and password for Dropbox every time that I use the app.
The app it's only for my use, it's not a security problem if the app auto-login in my account.
I don't find examples or documentation to make an auto-login with SwiftyDropbox. It's possible?
While the Dropbox API was designed with the intention that each user would link their own Dropbox account, in order to interact with their own files, it is technically possible to connect to just one account. We generally don't recommend doing so, for various technical and security reasons, but those won't apply if you're the only user anyway.
So, there are two ways to go about this:
1) Implement the normal app authorization flow as documented, and log in and authorize the app once per app installation. The SwiftyDropbox SDK will store the resulting access token for you, which you can programmatically re-use after that point each time using authorizedClient.
2) Manually retrieve an access token for your account and hard code it in to the app, using the DropboxClient constructor shown here under "Initialize with manually retrieved auth token".

Building Mobile Routes on a Rails Server api

I have been building out a server api for mobile developers to use for an iphone app. I have no experience with mobile development and they have no experience with ruby on rails. I have attempted to build a mobile authentication route for the app that allows users to log in via facebook. So far, it looks like this:
GET '/auth/mobile/fbtoken=:facebook_token&device_id=:device_id&time_zone=:time_zone&os_type=:os_type', to: 'sessions#fb_sso'
client = OAuth2::Client.new(
ENV['FACEBOOK_APP_ID'],
ENV['FACEBOOK_APP_SECRET'],
site: 'https://graph.facebook.com')
token = OAuth2::AccessToken.new(client, params[:access_token])
user_info = ActiveSupport::JSON.decode(token.get('/me').body)
The resources online for learning how to do this properly are very limited or nonexistant. The only information I have found on how to do this involves using Devise for authentication. Our app currently is equipped for Devise (it's been added and the migration has been made to the User model) but does not currently authenticate via Devise. One of the only specific examples that I have been able to find for what we're trying to do can be found at the bottom of the page on this post:
https://www.ruby-forum.com/topic/4409930
It led me to believe that I was on the right track with the way the route was set up, because everything is the same besides the last step "sign in using Devise method: sign_in #user, :event => :authentication." This is what motivated me to attempt to integrate Devise into our application.
After reading that, what I meant to do was implement Devise in a sort of limited state and use only the sign_in method. Unfortunately, Devise seems to be very opinionated and more of an "all or nothing" sort of solution. I'm very unsure of how to proceed and how to decide whether to completely rebuild a significant portion of our application to support Devise or to abandon it altogether and try to implement my own solution.
tl;dr
1) Is it worth re-doing a significant portion of the Rails app to use Devise?
2) Is it possible to make this route work without Devise? How?
If you are only going to have your users sign in through Facebook then Devise would be unnecessary as you would just be using Facebook's API with Koala or Omniauth to authenticate the user. On the other hand, I see no reason why you couldn't have both your own authentication and Facebook authentication by also using Devise if you want non-Facebook users to use your app; you would just need either form of authentication to create a session.
And if I understand correctly, the solution at the bottom of your link doesn't use Devise for Facebook authentication but it's used to create a session when a person's FB account has been authenticated. Seems like a reasonable way to go.
To answer your TL/DR:
1) Only if you plan on having both a Facebook login and a traditional login at the same time.
2) Yes. Just give those GET parameters to a gem like Omniauth or Koala and create a session once the user has been authenticated.

Web API FB OAuth? How would to go about implementing it in a SPA application?

Documentation on the net seems to be VERY scarce. The only option I can think of at the moment
is to have my SPA app break convention and to have the (initial) logged out page be different to the logged in one (eg my app).
My app is built using Durandal 2.0.0.
In one of my OAuth tests app's I've managed to implement this link successfully. But as Durandal does not work in the same way (Server-side controller, & razor views), I'm thoroughly confused in how to achieve what I want to.
I'd like to have my app remain a single page app. But I've got little to no experience with the OAuth SDK
My only requirement is that the user log into my app using his FB account.
I've had an initial stab at this using the FB java script API, and got it working, but after discussions with another developer this side, it doesn't seem like the purpose of the java script API is to facilitate secure application login's? As the way we had it, would allow any user to pass a valid fb userId, then he would be logged into our app. :/
How would I go about achieving this process flow in a Durandal/Web API Single Page App?
User logs in using fb ->
then on the server we get his fb userId ->
retrieve our internal appID
I'm not asking for a complete answer/for someone to do my work....
But any documentation to get me started/less confused would be greatly appreciated.
Here is a sample project which demonstrates how to use OAuth with Durandal and Web API:
DurandalAuth.
However there are some modifications in viewmodels needed, since router changed in Durandal 2.0.0.

how to post data on salesforce database from iphone application?

I am developing one iPhone application in which I want to post data on the salesforce database.
I have tried from google but not got any success.
Can you please guide me?
Thanks in Advance
Salesforce provides an iOS SDK to talk to their API:
https://github.com/forcedotcom/SalesforceMobileSDK-iOS
Here is a tutorial on getting started:
http://wiki.developerforce.com/page/Getting_Started_with_the_Mobile_SDK_for_iOS
You will need to use an Oauth flow to authenticate to the API. This means you show a Login page from Salesforce.com, the user logs in, and then your UIWebView will get a redirect with a sessionId in the URL. You can extract the sessionId and use it to talk to the API for read or write access, depending on the user's permissions. The SDK includes sample code that implements all of that, so you just need to merge that code in with your app.

Authenticating into Google App Engine from an iOS device

I am working on an iPhone application that uses Google app engine to host the backend. I need to authenticate with Google but I can't seem to find a way to do it from my app. It seems I am down to making a UIWebView to have a user sign in to the redirected login page I am getting from Google, but I would much rather have the user enter there credentials one time and then have it persist, unless the user signs out.
Is this possible? Should I be looking at other options or am I just not handling the redirect correctly?
Any suggestions or info would be appreciated.
Thanks
O-Auth is available on App Engine.
Just insert GTMOAuth in your projet and present the GTMOAuthViewControllerTouch. You'll be able to store the auth token in the user's keychain.
Then authorize your NSURLMutableRequests via [auth authorizeRequest:myNSURLMutableRequest]...
I think it might be easier than reusing and managing cookies.
This page has pretty complete information on how to access the built-in Signin flow that is included with the generated app-engine endpoint library:
https://developers.google.com/appengine/docs/python/endpoints/consume_ios