Saturday, August 4, 2018

Lightningout in W3 schools (Share Lightning Out Apps with Non-Authenticated Users)

Share Lightning Out Apps with Non-Authenticated Users


Paste the below code in the w3 schools which enables you to see the lightning component screen in the external site(w3school). As of my research this is the simple and best POC to show how the Lightning out works in the external sites.
====================================================================
<!DOCTYPE html>
<html>
<head>
<body>
<div id="lightning" />


<script src="https://oliva-developer-edition.ap5.force.com/dave/lightning/lightning.out.js"></script>

<script type="text/javascript">


window.onload= function(){

    $Lightning.use("c:CalciApp", function() {
          $Lightning.createComponent("c:Calci",
          {},
          "lightning",
          function(cmp) {
            // do some stuff
          });
        }, "https://oliva-developer-edition.ap5.force.com/dave");
     
}       
     
</script>
==================================================================

Add the ltng:allowGuestAccess interface to your Lightning Out dependency app to make it available to users without requiring them to authenticate with Salesforce. This interface lets you build your app with Lightning components, and deploy it anywhere and to anyone.
A Lightning Out dependency app with the ltng:allowGuestAccess interface can be used with Lightning Components for Visualforce and with Lightning Out.

The ltng:allowGuestAccess interface is only usable in orgs that have Communities enabled, and your Lightning Out app is associated with all community endpoints that you’ve defined in your org.

Note: When you make a Lightning app accessible to guest users by adding the ltng:allowGuestAccess interface, it’s available through every community in your org, whether that community is enabled for public access or not. You can’t prevent it from being accessible via community URLs, and you can’t make it available for some communities but not others.
IMP: this lightningout only works when you keep your community domain in the code. It wont work with your regular org domain.

For more details, please follow the below source.

Lightningout documentation

None of SSO users were able to login.

If SSO is down and you dont have option to login into the Salesforce org completely, don't worry there is a way system administrator can login into the org by hitting below URL 

<MyDomain URL>?login=1 


Replace My domain url with your companies domain name and try to login, you should be able to login.