legacy-knowledge-base
公開されました Jul. 2, 2025

カスタムポートレットにおけるJSON認証について

written-by

Justin Choi

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

LiferayはAPIをサポートし、API自体やLiferayのソフトウェアの他の部分と関係するあらゆる問題を解決し、あらゆる質問に回答します。 カスタム開発に関する問題や質問は、当社のグローバルサービスチームまたはそれらのカスタム化の開発者が対応することがあります。

お客様がカスタムポートレットにJSON認証を使用する場合、サービスコールに関するLiferay APIを含める必要があります。 そうしないと、ユーザーは2回目のサインイン認証が必要になる場合があります。 この記事では、カスタムポートレットを使用しているため、一部の情報は特定の環境に適合させる必要があります。

解像度

ポートレットをコンパイルする前に、ポートレットの view.jsp を適宜修正してください:

code>
	function callService2()
	{
	Liferay.Service('/api/jsonws/[custom portlet name].thing/find-all-things',
		function(obj) {
		    console.log(obj);
		  }
		);
	}
	

宛先

code>
	function callService2()
	{
	Liferay.Service('/[custom portlet name].thing/find-all-things',
		  function(obj) {
		    console.log(obj);
		  }
		);
	}	
  1. カスタムポートレットをコンパイルします。
  2. Liferayバンドルを起動します。
  3. すべてのデフォルトオプションを使用し、Hypersonicをデフォルトのデータベースとして残します。
  4. アプリケーションサーバーを停止します。
  5. portal-ext.propertiesを新たに作成し、以下のプロパティを設定します:
    code>
    		auth.token.check.enabled=false
    		json.service.auth.token.enabled=false
    		jsonws.web.service.public.methods=get*,has*,is*,save*,xx*,remove*,update*
    		json.service.public.methods=get*,has*,is*,save*,xx*,remove*,update*
    		
    		
  6. portal-ext.propertiesportal-setup-wizard.propertiesと同じディレクトリに配置します。
  7. ポータルを再起動する。
  8. カスタムポートレットをデプロイします。
  9. Cookieのセッション情報がない新しいブラウザウィンドウを開く。 Chromeをお使いの方は、インコグニートウィンドウ機能をご利用ください。 (例ではすべてChromeを使用します。 Firefox、Internet Explorerをお使いの方は、それぞれプライベートウィンドウ、InPrivate Browsingが該当します)。
  10. をクリック > マイ・プライベート・ページに移動します。
  11. Hello Worldという名前のプライベートページを作成します。 結果のURLは、 http://localhost:8080/group/[username]/hello-worldとなります。
  12. そのページにカスタムポートレットを追加します。
  13. ブラウザを閉じる。
  14. 新しいIncognito Chromeウィンドウを開き、2つのタブを表示します:
    • http://localhost:8080/
    • http://localhost:8080/[custom portlet name]/api/jsonws
  15. まだログインしないでください。 この時点で、ユーザーは2つ目のブラウザタブで認証を求められることになります。
  16. 2つ目のタブを閉じます。
  17. 最初のブラウザタブでポータルにログインする。
  18. http://localhost:8080/ [カスタムポートレット名]/api/jsonwsこの URL に新しいタブを開きます。 ユーザーが認証され、再ログインする必要がないことに注意してください。

追加情報

JSON Web Services (Liferay Portal 6.1 Developers Guide)。

did-this-article-resolve-your-issue

legacy-knowledge-base