【问题标题】:Salesforce integration with D2L Brightspace - oauth2.0 issuesSalesforce 与 D2L Brightspace 的集成 - oauth2.0 问题
【发布时间】:2017-07-10 16:03:18
【问题描述】:

我正在与一位客户合作,他将使用 Brightspace API 来构建 Salesforce 和 D2L 的 Brightspace 之间的集成。 我们目前正在尝试利用 Oauth2.0 来验证必要的 API 调用。我们已经在他们的 Brightspace 网站中创建了所需的 Oauth 应用程序。

发送以下请求时:

HttpRequest req = new HttpRequest();
//req.setEndpoint('callout:D2L');
String clientId = 'retrieved from registered app in Bspace';
String clientSecret = 'retrieved from registered app in Bspace';
String refreshToken = '';
String scope = 'core:*:*';
String redirectUri = 'https://test.salesforce.com/services/auth/oauth/00D0S0000000VTwUAM/D2L';
req.setEndpoint('https://auth.brightspace.com/oauth2/auth?response_type=code&client_id=' + clientId + '&client_secret=' +clientSecret+'&scope=' +scope);

//String reqbody = 'grant_type=refresh_token&client_id='+clientId+'&client_secret='+clientSecret;
//req.setBody(reqbody);
//req.setheader('client_id',clientId);
//req.setheader('client_secret',clientSecret);
req.setheader('grant_type','refresh_token');
//req.setheader('response_type','code');
req.setheader('redirect_uri',redirectUri);
//req.setheader('refresh_token',refreshToken);
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
System.debug('Response: ' + res);

他们收到以下内容...

错误信息: System.HttpResponse[状态=找到,状态代码=302]

对这里出了什么问题有什么想法吗?

麦克

【问题讨论】:

    标签: oauth-2.0 desire2learn


    【解决方案1】:

    得到这个工作。问题是由于 Salesforce 中的“D2L”应用程序的配置设置造成的。 SF 在 HTTP 请求的标头(而不是正文)中将 client_id 和 client_secret 发送到 D2L auth 服务至关重要。有 SF 配置,例如“生成授权标头”和“允许 HTTP 标头中的合并字段”定义了这一点。 一旦应用程序可以进行身份​​验证,Salesforce 管理员可以使用“apex”将 api 调用传递到 Brightspace,只需调用应用程序。即

    req.setEndpoint('callout:D2L/d2l/api/lp/1.9/enrollments/users/1928/orgUnits/6773');

    “D2L”是配置的应用程序。

    麦克

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多