0

we have an android app which is connected with Salesforce. From the Android app, we will pass the username and password to the salesforce to get oAuth token. I have created one checkbox field i.e. hasAccesstoAndroidApp__c on the user object. I need to get OAuth token from salesforce for a user who has hasAccesstoAndroidApp__c field value is true. For other users who have false value on the hasAccesstoAndroidApp__c field then need to pass the error message.

How we can implement this requirement.

Thanks,

  • Hi, Anup. Could you please edit your question and explain why you need this functionality? As it stands, this feels like an X-Y problem. I don't think this is a viable solution for whatever it is you're trying to do. – sfdcfox Dec 21 '18 at 16:17
  • 1
    You can only read user details after you have logged in. The solution suggested by blank seems the most appropriate use case. Also you can write a trigger on User Object, when the picklist value is populated you assign the permission set to the user and remove it when picklist value changes, – Pranay Jaiswal Dec 23 '18 at 10:55
2

It looks like you're trying to replicate the standard Salesforce functionality. Take a look at this article: https://help.salesforce.com/articleView?id=000230821&type=1

In a few words, you can give access to a connected app via permission set to specific users. From the question description, it looks like this is what you actually need.

Also, you can write a trigger on User Object, when the picklist value is populated you assign the permission set to the user and remove it when picklist value changes Thanks @(Pranay Jaiswal) for this option.

If I'm right please edit the question, to help others find the answer easily

  • Thanks, It worked for me. I have one more question. if user don't have permission to log in through the connected app. then it will give us standard error message. can we customize the error message? – Anup Kage Dec 28 '18 at 13:20
  • @AnupKage No, unfortunately you can't. But you can handle this error in the mobile app itself and display whatever message you prefer – blank Dec 28 '18 at 16:08

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.