In this blog post, we are going to see how to configure the twitter as auth provider to login into salesforce.
Registering new OAuth app in Twitter:-
1: go to https://apps.twitter.com/
2: Click on create a new app and fill the details under application details.
3.Name –<any meaning full name is fine >
4.Description * – <description about your application >
5.Website * – < your application website >
6.Callback URL – < leave it blank at this stage. we need to update this one with salesforce callback URL
7.Click on “Developer Agreement” terms and conditions then click on Create your twitter application.
After saving applications looks as shown below.
Now go to your application click on Keys and Access tokens tab to get your Consumer Key and Consumer Secret which are required to configure in salesforce auth provider.
Configuring Auth Provider in Salesforce:-
Now you need to configure the Twitter auth provider in salesforce.
Login into salesforce , Go to –> Setup –>Security Controls –> Auth. Providers –> Click on New from the Provider Type select Twitter. Fill the details as shown below.
1.Name – give it as Twitter
2.URL Suffix – give it as Twitter
3.Consumer Key – which your got from Keys and Access tokens tab from twitter application
4.Consumer Secret – which your got from Keys and Access tokens tab from twitter application
5.Custom Error URL leave it blank
6.Custom Logout URL leave it blank
7.Registration Handler – Click on Auto Generate
8.Execute Registration As Any System admin user
9.Portal – Leave it blank
10 .Icon URL – Leave it blank
now you need to update the callback URL in twitter application which got it from salesforce
go to twitter application which you created earlier -> click on Settings tabs -> update the callback URL with the salesforce callback URL as shown below. then click on update settings.
Go to Setup -> Domain Management -> My Domain under
“Authentication Configuration” setting Click edit check twitter in “Authentication Service” then save it.
Now go to your salesforce domain login URL you can option to login using twitter as shown below
Issue 1: – Twitter OAuth won’t share the user email as part of the OAuth API request. To solve this follow these steps
Go to https://support.twitter.com/forms/platform
Select “I need access to special permissions”
Enter Application Name and ID. These can be obtained via https://apps.twitter.com/ — the application ID is the numeric part in the browser’s address bar after you click your app.
Permissions Request: “Email address”
Submit & wait for response
After your request is granted, an addition permission setting is added in your twitter app’s “Permission” section. Go to “Additional Permissions” and just tick the check box for “Request email addresses from users”.
Issue 2: –
The Twitter won’t support refresh token as per the document.