Salesforce OAUTH implementation - ios

I'm developing Salesforce iOS application.
From application frequently the user has to modify data which is available on Salesforce.com.
When user tap on edit I'm launching salesforce login screen and prompt to enter username and password all the time.
So I have decided to implement SSO using Salesforce Oauth. I have done everything I'm able to receive a access_token once user authenticate with Salesforce.com.
My question is lets say "If the user want to edit a lead with id as 0097hjy7" , URL to edit this lead will be "https://sales.mysalesforce.com/0097hjy7" when this URL launch on browser it prompt to enter username and password again.
How can I navigate the user to "https://sales.mysalesforce.com/0097hjy7" this URL without asking username and password all the time by using the access_token available with me.
Thanks in advance.

I resolved this issue by adding Salesforce iOS SDK to my project and using some classes like SFOauthCoordinator and SFOauthCredentials. At the end we need to prepare a frontDoorUrlWithReturnUrl which is available on "SFAuthenticationManager" class.

Related

zendesk - enduser login with username and password

We are developing a mobile app.
In this app we want our END USER to able to login with there email id + the password they have from our zendesk.
I can not find any way to let a END USER login with email + password. And after that, make tickets and see his open tickets.
We are using the CORE API at this point.
Have you had a look at the docs for the iOS and Android SDKs?
You can set up an AnonymousIdentity with email and name after your users auth into your app. This will give you an identity which can be used to create tickets.
There are limitations with AnonymousIdentity, described in the docs. The other option is JwtIdentity, this requires a bit of backend development to get up and running.

Facebook acoount login in webview

I want to know that is there any way to login my account in webview by picking username and password from textfields and load it in webview?
Basically I want to make an custom username and password fields. When user put fb name and password on it, it send request to facebook with username and password for login in webview for use facebook in webview. If username and password is correct then it save on NSUserDefaults for next time automatically login.
Please can anyone tell me how I can achieve functionality like this.
What you are asking is actually quit a common thing to do now days.
It is called social login, also known as social sign-in, that is a form of single sign-on using existing information from a social networking service such as Facebook, Twitter or Google+.
There is an official way to do this, you can check Facebook Documentation which guide you step-by-step on how to do this (pretty straight forward).
Basically you need to use Facebook Login Kit and they will handle the part where they present a webView and asking for credentials. You will get an access token which you can then store in the device (Keychain is much preferred from NSUserDefaults)
Note: The method you described in your question, where you ask the user for username and password store them and inject them to a web view is super not secure and is defiantly not the intent of Facebook API to use.

How to know user has already done Facebook login at iOS app

I am developing iOS App which use Facebook iOS SDK 4.
When user has already done Facebook login, by doing Facebook login the dialog which shows "user has already approved your app" had be displayed.
So, do not show the dialog. I want to know whether the user has already done Facebook login.
Anyone know the good way? I think accessToken is returned if user once had done Facebook login.
FBSDKAccessToken manage current logged user's accessToken.
According to official Facebook Login guide
"FBSDKAccessToken Represents the access token provided by a successful login. Most important, it provides a global +currentAccessToken to represent the currently logged in user."
The currentAccessToken is a convenient representation of the token of the current user and is used by other SDK components (like FBSDKLoginManager).
According to above you can check either user has valid accessToken or not and based on this you can track call login method otherwise just skip to next flow.
In Facebook the access tokens are per user so you can pass them around apps and they will work. In your case if you can ship an access token from another app you will be able to skip the next logging in and use the API normally.
However I think this this thread will help you.
Things are a little bit different with iOS cause I have done a facebook login on Android and got no such issues.

phonegap iOS facebook Re-Authentication issue

I am using Cordova 3.4.0 along with the official facebook connect plugin link
The issue is that every time user opens the application. He/She has to press login and then it shows the "App already authorized screen" before the user is able to perform any action. How to prevent this addition of an action in the user flow?
I read that it is basically because the access token isn't stored by the plugin. As a result this action needs to be taken again and again. So I have now stored access token using localstorage but unfortunately don't know how to go about using it.
FB.api('/me/friends?access_token="+access_token+"', { fields: 'id, name, picture' },
Using it in the manner above results in an error saying invalid oAuth access token. Even though I placed an alert before this line to ensure that access_token had a valid value. Any help in this regard would be highly appreciate.
Just to rephrase I don't want the user to be asked to press login button every time they open the application.

How to parse a web page that has login and password to enter in to view user's personal page? (iphone)

How do I parse a webpage with login and password requirements to view the individual user's information, like facebook for example. I want my app to access to the individual facebook page, after entering login and password in the app.
By now I was able to parse usual webpages with TFHpple, but I have no idea how to pass the login and password requirements to get the page content.
Thank you very much in advance!
Usually the process for logging in is:
User POSTs data to a login form with username and password.
The server responds with a session cookie
Future requests include the session cookie and the server knows that the user is authenticated.
If you wan to do this login process on your user's behalf through our app, you'll need to save the cookies and send them on subsequent requests.
Why don't you use the Facebook iOS SDK:
https://developers.facebook.com/docs/ios/
I think it's a little bit strange from the architecture perspective that you want to parse the personal Facebook newsfeed, when there's the possibility to get the data via the Facebook API (given that you have the appropriate User Permission)...

Resources