Canvas の使用
署名付き要求や OAuth 2.0 プロトコルなどの認証方式を必要とする外部アプリケーションに Open CTI を統合するには、Canvas を使用することをお勧めします。
Canvas と Open CTI は似ています。これらはツールと JavaScript API のセットで、開発者がサードパーティシステムを Salesforce に追加するために使用できます。ただし、Canvas の利点の 1 つとして、認証方式を選択できるという点があります。
When developing a canvas app, and you want to include functionality from Open CTI, do the following:
- Include the Open CTI API in index.jsp.
-
Sfdc.canvas.client.signedrequest() をコールし、コンソールインテグレーションツールキット API に必要な署名付き要求を保存します。たとえば、Canvas の認証方式が署名付き要求の場合は、次を実行します。
1Sfdc.canvas.client.signedrequest('<%=signedRequest%>')If the Canvas method of authentication is OAuth, do the following in the callback function used to get the context, as shown in the Canvas Developer Guide:
1Sfdc.canvas.client.signedrequest(msg)
Consider the following when working with Open CTI and canvas apps:
- The Open CTI API script depends on the signed request and should be added after the call to Sfdc.canvas.client.signedrequest() has executed. スクリプトを動的に読み込むことをお勧めします。
- キャンバスのサイドバーコンポーネントに関連付けられているレコードのエンティティ ID を取得するには、次を実行します。
1// Get signedRequest 2var signedRequest = Sfdc.canvas.client.signedrequest(); 3var parsedRequest = JSON.parse(signedRequest); 4// get the entity Id that is associated with this canvas sidebar component. 5var entityId = parsedRequest.context.environment.parameters.entityId; - OAuth の entityId を取得するには、次を実行します。
1var entityId = msg.payload.environment.parameters.entityId;To see an example on how to retrieve msg.payload, see the Canvas Developer Guide.