Salesforce and Xero Integration Using OAuth 2.0

        In this article I am going to explain the steps to integrate Salesforce and Xero by using OAuth 2.0, the latest version of xero authentication.

Note: OAuth 1.0a will no longer be supported for any apps.

I am going to connect the salesforce and xero with 'OpenID Connect' authentication. If you want learn more about openID connect click here.

Create a app in Xero:

1. Open the below link and click 'New app' in right corner.
           https://developer.xero.com/myapps/

2. Provide the details as mentioned below
          App name: Demo (You can give any name)
          OAuth 2.0 grant type: Auth code (Web app)
          Company or application URL:
          https://lweb-dev-ed.lightning.force.com/services/auth/oauth/XeroAuthProvider
          <Salesforce domain URL>/services/auth/oauth/<name of the auth. provider which are going to create in the next step>
          OAuth 2.0 redirect URI:
          https://lweb-dev-ed.lightning.force.com/services/authcallback/XeroAuthProvider
          <Salesforce domain URL>/services/authcallback/<name of the auth. provider which are going to create in the next step>




3. Agree the terms and condition and click 'Create app'. Now you are on the App detail screen. Click ‘Generate Secret’ button to create the secret key.

4. Copy both the Client id and Client Secret and keep it in a separate note pad. We need this for our next step.
       
Create a Auth. Provider and Named Credential in Salesforce:

1.  In Salesforce go to Setup --> enter 'Auth' in the quick find and select the 'Auth. Providers'. Click 'New' and select 'Open ID Connect'. As I mentioned earlier I am going to connect open ID connect for integration.

2. Enter the details as mentioned below

           Name: XeroAuthProvider
           URL Suffix: This will be auto populated leave it as it is.
           Consumer Key: Paste the client id which you copied on the step 4
           Consumer Secret: Paste the client secret which you copied on the step 4.
           Authorize Endpoint URL: https://login.xero.com/identity/connect/authorize
           Token Endpoint URL: https://identity.xero.com/connect/token
           Include Consumer Secret in API Responses: Uncheck this checkbox

     Click Save. Now you are on the Auth. Provider detail page, on this page there is a section called 'Salesforce configuration' with 'OAuth-Only Initialization URL' and 'Callback URL'. Make sure this URL is same as in xero app which we create in the above steps. If this URL is not matching then connection won't be success.

3. Lets create a 'Named credentials'. Go to setup --> enter 'Named' in the quick find and select the Named Credentials --> click 'New'.  Enter the details as below.

       Label: XeroDemo
       Name: It will be auto populated as label. Leave it as it is.
       URL: https://api.xero.com/
       Identity Type: NamedPricipal
       Authentication Protocol: OAuth 2.0
       Authentication Provide: Select ‘XeroAuthProvider’ which you created in the previous step.
       Scope: openid offline_access accounting.settings.read
       Start Authentication Flow on Save: Check the checkbox.
       Allow Merge Fields in HTTP Header: Check the checkbox.

   Click 'Save', it will take you to the Xero login page(if you are not logged into xero). Once you entered the details you have the ability to select the xero organisation to be accessed from salesforce.
After the select click continue and you will be redirected to salesforce.

Note: Even the scope can be defined on the auth provider default scope.

Verify the connection:

If you run the below code in your developer console and if you get the status code as 200 then you are successfully connected the salesforce and xero.



Please let me know your thoughts on the comment.







Quarantine Activity as Salesforce Admin & Consultant

     In this post I am going to suggest few activity for admins and consultants who are supporting the business in this quarantine time.

1. Updating the account and contact database:
           Speak to the sales and marketing team to update the current account and contact database. There are few way as a admin/consultant you can support this activity.

            1.1. Creating reports on duplicate records: Duplicate records will be displayed only when you have enabled 'Report' option on the duplicate rule. If you enable now then it will work only for the future records. You have to update the existing records to get the duplicate record item to be created.
Below URL will help you to create the report on duplicate records.
            https://help.salesforce.com/articleView?id=duplicate_management_custom_report_types.htm&type=5

            1.2. Stay-in-Touch: As you already know stay in touch is retired with summer'17 release, but there is a free app exchange package called 'Contact Update Request' will help you with this stay-in-touch. By using this you can keep contact with current information.

            1.3 You can use the free data quality analysis tool to find out your data quality.
             https://appexchange.salesforce.com/appxListingDetail?listingId=a0N300000016cshEAA

2. Ask the marketing team to create the target list after the quarantine.
         This can be done by creating the campaign and adding the target audience.

3. Go through the business process with the team and make sure the system function is matching with the business process. If it's not you can plan for the enhancement.

4. Arrange a webinar session with team and educate the system process and features.

5. Optimizer: Run the optimizer report to review the current implementation and work on the recommendation which you have received in the report. 

6. Health Check: Review the standard health check page to make sure it meets the security standard.

7. Upgrading existing package: Client might be using some paid installed packages. Please check with the provider and make sure it is with the latest version. If it is not then plan the upgrade and educate the team with new features.

8. Upgrading the classes: As a maintenance activity you can update the classes with the latest release.
This needs to be first done in sandbox and then deployed to Production.

9. You can clean the metadata and unused fields. You can use Field Trip appexchange tool to find out the unused fields

In this there are few item which you might be already doing as a org maintenance but if you haven't then this might be a right time to do this. If you are doing any other activity please let me know in comment.