<commit_before>// Module included in the following assemblies:
//
// * authentication/configuring-internal-oauth.adoc

[id="oauth-configuring-internal-oauth_{context}"]
= Configuring options for the internal OAuth server

You can configure default options for the internal OAuth server's
token duration.

.Procedure

. Set the token duration options:
+
[source,yaml]
----
oauthConfig:
  ...
  tokenConfig:
    accessTokenMaxAgeSeconds: 86400 <1>
----
<1> Set `accessTokenMaxAgeSeconds` to control the lifetime of access tokens.
The default lifetime is 24 hours, or 86400 seconds. This attribute cannot
be negative.<commit_msg>BZ-1694686: Updated steps on the internal timeout.<commit_after>// Module included in the following assemblies:
//
// * authentication/configuring-internal-oauth.adoc

[id="oauth-configuring-internal-oauth_{context}"]
= Configuring the internal OAuth server's token duration

You can configure default options for the internal OAuth server's
token duration.

[IMPORTANT]
====
By default, tokens are only valid for 24 hours. Existing sessions
expire after this time elapses.
====

If the default time is insufficient, then this can be modified using
the following procedure.

.Procedure

. Create a configuration file that contains the token duration options. The
following file sets this to 48 hours, twice the default.
+
[source,yaml]
----
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
  name: cluster
spec:
  tokenConfig:
    accessTokenMaxAgeSeconds: 172800 <1>
----
<1> Set `accessTokenMaxAgeSeconds` to control the lifetime of access tokens.
The default lifetime is 24 hours, or 86400 seconds. This attribute cannot
be negative.

. Apply the new configuration file:
+
[NOTE]
====
Because you update the existing OAuth server, you must use the `oc apply`
command to apply the change.
====
+
----
$ oc apply -f </path/to/file.yaml>
----

. Confirm that the changes are in effect:
+
----
$ oc describe oauth.config.openshift.io/cluster
...
Spec:
  Token Config:
    Access Token Max Age Seconds:  172800
...
----
{'fraction_non_alphanumeric': 0.098488542174549, 'fraction_numerical': 0.022915650901999023, 'mean_word_length': 4.066666666666666, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2549656', 'n_tokens_mistral': 625, 'n_tokens_neox': 576, 'n_words': 237}