I am new salesforce and have good knowledge of java and android development.. Since the Default authection of salesforce template app uses web view I want to do it without using web view through some posts I found that it is possible by using Username-password flow but my question is is it possible to implement it in android.If so then how


You're not expected to use this flow, so it is unlikely that the Android mobile toolkit would include code to do this. It is a security risk, and it also is a red flag that will prevent your app from passing a security review and being listed on the AppExchange.

If you really want to do this, you're going to have to write all the logic for it yourself, by modifying the imported library code. Assuming you're a competent Android developer, you should already know how to use a HTTPS connection to acquire a resource. There's no special magic you need to do. Simply provide the correct parameters, listed in the documentation, to the correct endpoint, and you'll be logged in.

  • I am able to get everything except refresh token.But it is needed by LoginOptions – Goutam Feb 24 '15 at 21:21
  • 1
    @Goutam That's because the Username-password flow does not give you a Refresh Token. You're not supposed to use that flow. I'm pretty sure the entire Mobile SDK would be useless without a major rewrite if you wanted to support this flow. You'd probably be better off writing your own toolkit. – sfdcfox Feb 24 '15 at 21:24
  • Then how do we get rid of the webveiew,Are every native apps buit on mobile sdk use the web view to authenticate? – Goutam Feb 24 '15 at 21:32
  • 1
    @Goutam I believe so; they need to be able to render a page to allow authentication, and they could hardly do so unless they were willing to use a webview or write their own mobile browser just to display an authorization dialog. – sfdcfox Feb 24 '15 at 21:55
  • This webview is creating the first bad impression. Is this problem not yet solved.. Or still I have to render the web page – Goutam Jan 15 '16 at 17:30

Not clear what you are trying to do. But from Username-password flow I guess you are looking are looking for ways to authenticate a salesforce user using their login credentials?

If so, you can use Salesforce Partner API login operation, which takes userid/password and creates a session. Later you can use that session id to invoke other apis.

  • I want aunthneticate my android app using Username-password flow.I know the thing what you said but I dont know how to do it in mobile sdk(Android) – Goutam Feb 24 '15 at 18:18
  • Sorry, this answer doesn't help much if questions is specific to Mobile SDK. – singularity Feb 24 '15 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.