但我无法捕获访问令牌,因为在第7步之前执行了第4步。因此,无法捕获访问令牌。如果有获取/捕获访问令牌的方法,请务必让我知道。
client side controller code (**using window object**):
({ AuthTargetOrg : function (component, event, helper) {
var endpturl = 'https://test.salesforce.com/services/oauth2/authorize?response_type=token&client_id=abc123&redirect_uri=https%3A%2F%2Fbusiness-momentum-162-dev-ed.lightning.force.com%2Fservices%2Foauth2%2Fsuccess';
window.open(endpturl,'_self');
var currLoc = window.location.href;
alert ('Curr Loc is: ' + currLoc); // prints home page URL from where I clicked "auth target org" button, rather this statement expected to execute after step 7.
)}
致敬,PJS
发布于 2018-09-19 06:22:01
我认为您需要使用Apex来处理Oauth舞蹈的重定向。我自己一直在努力解决这个问题,问题是在lightning组件中,你不能直接对salesforce端点进行API调用,它会抛出各种错误。然而,我确实找到了这个代码示例:
https://balkishankachawa.wordpress.com/tag/oauth-with-lightning/
基本上,解决方案是使用Apex和Lightning Out。使用Apex接收来自Salesforce身份验证的重定向,该身份验证可以获得令牌并将其传递回lightning组件。
https://stackoverflow.com/questions/51415990
复制相似问题