Create OAuth2 Application from JAVA code in portletCreate OAuth2 Application from JAVA code in portlethttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1214155292024-03-28T09:28:41Z2024-03-28T09:28:41ZRE: Create OAuth2 Application from JAVA code in portletStian Sigvartsenhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1214163692022-05-06T17:05:40Z2022-05-06T12:26:18Z<p>Hi Robert.</p>
<p>Looks like you added a dependency on the OAuth 2 service
implementation JAR and not its API.</p>
<p>The one you want is: com.liferay.oauth2.provider.api</p>
<p>A good example for how to use this API can be found here:</p>
<p>https://github.com/liferay/liferay-portal/blob/a165740c8b1bdbf95c8f89b39cf6738e73b57d0b/modules/apps/oauth2-provider/oauth2-provider-shortcut/src/main/java/com/liferay/oauth2/provider/shortcut/internal/instance/lifecycle/FragmentRendererPortalInstanceLifecycleListener.java#L65-L86 </p>
<p>The scopes assignment is probably the most tricky part, but hopefully
with that example you can get it something working.</p>
<p>Let me know how you get on :)</p>
<p>-Stian</p>Stian Sigvartsen2022-05-06T12:26:18ZCreate OAuth2 Application from JAVA code in portletRobert Woodfinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1214155282022-05-05T15:52:59Z2022-05-05T13:49:37Z<p>I am using Eclipse IDE with Liferay version 7.1.3.</p>
<p>I need to be able to create a OAuth 2 Application via code rather
than doing it manually from Control Panel/Configuration/OAuth 2 Administration.</p>
<p>This is just a POC, so the Java code will initially be in a
background Portlet MVCPortlet Class. </p>
<p>I have this as an external depenance - <strong>com.liferay.oauth2.provider.service-1.0.2-sources.jar</strong></p>
<p>I have this in my module build.gradle - <strong>compileOnly group:
"com.liferay", name: "com.liferay.oauth2.provider.service"</strong></p>
<p>I have been looking at
using OAuth2ApplicationServiceImpl.addOAuth2Application(...) But I am
not familiar enough with JAVA to get this working. I assume it needs
an import into the portlet.java file.</p>
<p>If anyone has any ideas, I'd b