Giter Site home page Giter Site logo

adityanaag3 / lwc-oss-oauth Goto Github PK

View Code? Open in Web Editor NEW
18.0 2.0 9.0 4.38 MB

Sample Code for connecting to Salesforce using OAuth Web Server flow from an LWC OSS App

License: Creative Commons Zero v1.0 Universal

JavaScript 76.55% HTML 11.54% CSS 11.91%
lwc-oss salesforce

lwc-oss-oauth's Introduction

Salesforce Integration with LWC OSS using OAuth Web Server Flow

This repo has the sample code for connecting to Salesforce using OAuth Web Server flow from an LWC OSS App.

About the app

The basic version of the app is built using the Trailhead Project Build Your First Application with Lightning Web Components Open Source.

The Salesforce Data Model for the app is created using the first 3 units of the Trailhead Project Access Salesforce Data with Lightning Web Components Open Source.

Logout Variations

The logout functionality is implemented in 2 different ways

  1. Logging out of the app, doesnt log you out of your active Salesforce session. The code for this is present in the master branch
  2. Logging out of the app also logs you out of your active Salesforce session. The code for this is present in the single-logout branch.

Using the app

  1. Create a connected app in your Salesforce Org

    1. Add http://localhost:3001/oauth2/callback to the list of Callback URLs.
    2. Add api to the list of Selected OAuth Scopes
  2. Note the Consumer Key and Consumer Secret.

  3. Clone this repository:

    git clone https://github.com/adityanaag3/lwc-oss-oauth
    cd lwc-oss-oauth
    
  4. Create a .env file at the root of the project, and add the following code:

    SALESFORCE_LOGIN_DOMAIN='https://login.salesforce.com'
    SALESFORCE_CLIENT_ID='YOUR_SALESFORCE_CONSUMER_KEY'
    SALESFORCE_CLIENT_SECRET='YOUR_SALESFORCE_CONSUMER_SECRET'
    SALESFORCE_CALLBACK_URL='http://localhost:3001/oauth2/callback'
    NODE_SESSION_SECRET_KEY='SOME_RANDOM_SECRET_KEY'
    
  5. Run npm install. (Refer to package.json for the dependencies that'll be installed)

  6. Run npm run watch. This will start the project with a local development server.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.