<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Create OAuth2 Application from JAVA code in portlet</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121415529" />
  <subtitle>Create OAuth2 Application from JAVA code in portlet</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121415529</id>
  <updated>2026-04-08T02:18:07Z</updated>
  <dc:date>2026-04-08T02:18:07Z</dc:date>
  <entry>
    <title>RE: Create OAuth2 Application from JAVA code in portlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121416369" />
    <author>
      <name>Stian Sigvartsen</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121416369</id>
    <updated>2022-05-06T17:05:40Z</updated>
    <published>2022-05-06T12:26:18Z</published>
    <summary type="html">&lt;p&gt;Hi Robert.&lt;/p&gt;
&lt;p&gt;Looks like you added a dependency on the OAuth 2 service
  implementation JAR and not its API.&lt;/p&gt;
&lt;p&gt;The one you want is: com.liferay.oauth2.provider.api&lt;/p&gt;
&lt;p&gt;A good example for how to use this API can be found here:&lt;/p&gt;
&lt;p&gt;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 &lt;/p&gt;
&lt;p&gt;The scopes assignment is probably the most tricky part, but hopefully
  with that example you can get it something working.&lt;/p&gt;
&lt;p&gt;Let me know how you get on :)&lt;/p&gt;
&lt;p&gt;-Stian&lt;/p&gt;</summary>
    <dc:creator>Stian Sigvartsen</dc:creator>
    <dc:date>2022-05-06T12:26:18Z</dc:date>
  </entry>
  <entry>
    <title>Create OAuth2 Application from JAVA code in portlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121415528" />
    <author>
      <name>Robert Woodfin</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121415528</id>
    <updated>2022-05-05T15:52:59Z</updated>
    <published>2022-05-05T13:49:37Z</published>
    <summary type="html">&lt;p&gt;I am using Eclipse IDE with Liferay version 7.1.3.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;This is just a POC, so the Java code will initially be in a
  background Portlet MVCPortlet Class. &lt;/p&gt;
&lt;p&gt;I have this as an external depenance - &lt;strong&gt;com.liferay.oauth2.provider.service-1.0.2-sources.jar&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I have this in my module build.gradle - &lt;strong&gt;compileOnly group:
    &amp;quot;com.liferay&amp;quot;, name: &amp;quot;com.liferay.oauth2.provider.service&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;If anyone has any ideas, I'd be grateful to hear them.&lt;/p&gt;
&lt;p&gt;Thanks...in advance.&lt;/p&gt;</summary>
    <dc:creator>Robert Woodfin</dc:creator>
    <dc:date>2022-05-05T13:49:37Z</dc:date>
  </entry>
</feed>
