# Making an API call in java behind the scenes

**URL:** <https://devforum.okta.com/t/making-an-api-call-in-java-behind-the-scenes/22439>\
**Category:** OAuth/OIDC\
**Tags:** api, java\
**Created:** [November 15, 2022, 10:36am UTC](https://devforum.okta.com/t/making-an-api-call-in-java-behind-the-scenes/22439 "2022-11-15T10:36:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dina.farbman](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@dina.farbman](https://devforum.okta.com/u/dina.farbman)\
**Post date:** [November 15, 2022, 10:36am UTC](https://devforum.okta.com/t/making-an-api-call-in-java-behind-the-scenes/22439/1 "2022-11-15T10:36:16Z")

</div>

Hi,

I have a Java app, and I need to integrate OKTA.

I need to login to the app with an okta account, and get the user’s group list from OKTA.

I got the login part working (authorization code flow).

When the groups are included in the token (“claims”) – I’m good.

But I need help with the groups fetching in an API call – because I need to support “no groups claims” scenario.

I can’t use Spring, so I’m coding against the protocol, on server side.

I need to make the API call for the groups behind the scenes, silently, with an access token (can’t use an API token).

1 – is there a permission I need to add to the user to enable the API call?

2 -Do I need to request a special access token for the API call? How?

3 – When I call {okta-url}/api/v1/users/me in the browser window, I see a lot of cookies being sent, including ‘sid’ (identifies the session?). How can the server side get these cookies (or just the sid cookie) without involving the browser?

4 – Any other info on this is welcome

Thanks in advance

---

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://devforum.okta.com/u/warren)\
**Post date:** [November 15, 2022, 4:44pm UTC](https://devforum.okta.com/t/making-an-api-call-in-java-behind-the-scenes/22439/2 "2022-11-15T16:44:58Z")

</div>

You could try using OAuth for Okta API but it only works with access tokens granted by the Org Authorization server. The `okta.groups.read` scope should allow you to retrieve the groups for that user.

> **[Implement OAuth for Okta | Okta Developer](https://developer.okta.com/docs/guides/implement-oauth-for-okta/main/)**
>
> Secure, scalable, and highly available authentication and user management for any app.

> **[Authorization servers | Okta Developer](https://developer.okta.com/docs/concepts/auth-servers/#org-authorization-server)**
>
> An overview of what an authorization server is and the types of authorization servers available at Okta.

The downside is that you lose the benefits of using a custom authorization server (custom claims, custom scopes, etc).

Another potential issue is that you can not validate an access token minted by the Org authorization server locally such as using a JWT verifier.  
[https://support.okta.com/help/s/article/Signature-Validation-Failed-on-Access-Token](https://support.okta.com/help/s/article/Signature-Validation-Failed-on-Access-Token)

---

<div class="post-metadata">

**Author:** ![gpadma](https://avatars.discourse-cdn.com/v4/letter/g/858c86/32.png) [@gpadma](https://devforum.okta.com/u/gpadma)\
**Post date:** [November 15, 2022, 5:15pm UTC](https://devforum.okta.com/t/making-an-api-call-in-java-behind-the-scenes/22439/3 "2022-11-15T17:15:48Z")

</div>

`okta.users.read` scope would be the scope for getting the groups of the current logged in user (/api/v1/users/me/groups)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [February 12, 2024, 10:21pm UTC](https://devforum.okta.com/t/making-an-api-call-in-java-behind-the-scenes/22439/4 "2024-02-12T22:21:08Z")

</div>

Closed on February 12, 2024, 10:21pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
