0

我在我的 Angular 应用程序中使用 forcejs,它运行良好并给了我 accessToken。但是,我无法让 refreshToken 能够根据需要更新 accessToken。代码如下

import { OAuth, DataService } from 'forcejs';

 async loginSFDC(){
    let callbackUrl = 'https://my.callback.url'

    let oauth = OAuth.createInstance('client key','', callbackUrl);
    oauth.login().then(
      
      async (oauthResult) => {
            DataService.createInstance(oauthResult);
            console.log("Logged Into Salesforce Successfully:::" + JSON.stringify(oauthResult)); 
           
    });
  }

上面的代码正在打印 accessToken 但没有 refreshToken。请指教

我还尝试将 createInstance 中的第二个参数作为http://login.salesfoce.com?scope=full+refresh_token传递,但这不起作用,因为在添加 scope=full+refresh_token 时 url 构造错误

4

2 回答 2

0

通过查看forcejs的源代码,您可以将 refreshAccessToken() 方法与您创建的 DataService 实例一起使用。

于 2020-10-31T07:09:50.840 回答
0

After some more debugging it is discovered that the refresh token shows up when my code is running on localhost but does not when it is deployed to the the webserver. i dont know how to debug further or fix it. but i have verified that this behavior is consistently reproducible

于 2020-11-06T02:30:52.180 回答