# Getting access\_token without a UI

**URL:** <https://devforum.okta.com/t/getting-access-token-without-a-ui/1009>\
**Category:** OAuth/OIDC\
**Created:** [January 8, 2018, 9:31pm UTC](https://devforum.okta.com/t/getting-access-token-without-a-ui/1009 "2018-01-08T21:31:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![derekclifford](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/derekclifford/32/281_2.png) [@derekclifford](https://devforum.okta.com/u/derekclifford)\
**Post date:** [January 8, 2018, 9:31pm UTC](https://devforum.okta.com/t/getting-access-token-without-a-ui/1009/1 "2018-01-08T21:31:45Z")

</div>

I’m trying to write some test automation around an API that uses okta authentication. The previous flow (before we implemented okta) did a simple user/pass authentication as a POST request, and returned a session token for me to use. What is the best way to do this with okta? I have user credentials to use, however all of the documentation I’m reading requires that I hit the UI (pass in a redirect\_uri).

I want to simulate a user after they’ve logged into okta, with their username/password (I’m not trying to test okta authentication, I’m trying to test the api as a user that has already logged into okta).

Looking at this endpoint, I _think_ this is the one I want, however it requires a `redirect_uri`, which I assume means I’m going to need a browser running:

> **[OpenID Connect & OAuth 2.0 API | Okta Developer](https://developer.okta.com/docs/reference/api/oidc/)**
>
> Find information about the OAuth 2.0 and OpenID Connect endpoints that Okta exposes on its authorization servers.

What endpoint(s) and/or configuration should I set up to be able to do this? Using selenium or another browser based testing tool is not something I should have to consider here.

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [January 8, 2018, 9:35pm UTC](https://devforum.okta.com/t/getting-access-token-without-a-ui/1009/2 "2018-01-08T21:35:54Z")

</div>

You can use `grant_type=password` and then you don’t need to specify a `redirect_uri`. This will give you similar functionality to what you had before. However, it’s probably more secure to use basic auth with client id / client secret, which is documented just a bit below the link you mention.

---

<div class="post-metadata">

**Author:** ![derekclifford](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/derekclifford/32/281_2.png) [@derekclifford](https://devforum.okta.com/u/derekclifford)\
**Post date:** [January 9, 2018, 10:37pm UTC](https://devforum.okta.com/t/getting-access-token-without-a-ui/1009/3 "2018-01-09T22:37:21Z")

</div>

We ended up using `grant_type=password` and that worked pretty well.

Thanks for the quick reply!

---

<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:** [January 12, 2024, 10:01pm UTC](https://devforum.okta.com/t/getting-access-token-without-a-ui/1009/4 "2024-01-12T22:01:44Z")

</div>

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