From e6c82192a05acf29738651982939673d6a6fd2c2 Mon Sep 17 00:00:00 2001 From: genwhittTTD Date: Thu, 19 Sep 2024 16:15:48 -0400 Subject: [PATCH] add content per CM --- docs/ref-info/ref-tokens.md | 30 +++++++++--- .../current/ref-info/ref-tokens.md | 48 +++++++++++++++++++ 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/docs/ref-info/ref-tokens.md b/docs/ref-info/ref-tokens.md index ab62b5b9a..337650335 100644 --- a/docs/ref-info/ref-tokens.md +++ b/docs/ref-info/ref-tokens.md @@ -57,21 +57,37 @@ An easy way to manage token refresh is to use one of the UID2 SDKs that have a f Each of these SDKs includes a class, `Uid2PublisherClient`, that has a function to determine if a token refresh is needed. -The following examples show how you could check if refresh is needed using one of these functions. The function checks whether you should refresh, and then, if needed, you can easily call the refresh function to refresh the token. +The following examples show how you could first check if the token can be refreshed and then check if refresh is needed, using one of these SDKs. If it's time to refresh, you can then call the refresh function to refresh the token. - ```java - if (identity.isDueForRefresh()) {..} - ``` +1. Determine if the identity can be refreshed (that is, the refresh token hasn't expired): + + ```java + if (identity == null || !identity.isRefreshable()) { we must no longer use this identity (for example, remove this identity from the user's session) } + ``` + +1. Determine if a refresh is needed: + + ```java + if (identity.isDueForRefresh()) {..} + ``` -```py - if identity.is_due_for_refresh()): -``` +1. Determine if the identity can be refreshed (that is, the refresh token hasn't expired): + + ```py + if not identity or not identity.is_refreshable(): # we must no longer use this identity (for example, remove this identity from the user's session) + ``` + +1. Determine if a refresh is needed: + + ```py + if identity.is_due_for_refresh()): + ``` diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/ref-info/ref-tokens.md b/i18n/ja/docusaurus-plugin-content-docs/current/ref-info/ref-tokens.md index 258bf4865..337650335 100644 --- a/i18n/ja/docusaurus-plugin-content-docs/current/ref-info/ref-tokens.md +++ b/i18n/ja/docusaurus-plugin-content-docs/current/ref-info/ref-tokens.md @@ -6,6 +6,8 @@ sidebar_position: 06 --- import Link from '@docusaurus/Link'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; # UID2 Tokens and Refresh Tokens @@ -49,6 +51,52 @@ The recommended refresh interval is hourly. To determine when to refresh, you can use the timestamp of the `refresh_from` field in the response to the [POST /token/generate](../endpoints/post-token-generate.md) endpoint (see [Successful Response](../endpoints/post-token-generate.md#successful-response)) or [POST /token/refresh](../endpoints/post-token-refresh.md) endpoint (see [Successful Response With Tokens](../endpoints/post-token-refresh.md#successful-response-with-tokens)). The value of this field is a timestamp in UNIX time, expressed in milliseconds. +### Managing Token Refresh with an SDK + +An easy way to manage token refresh is to use one of the UID2 SDKs that have a function for the purpose: either the Java or Python SDK. + +Each of these SDKs includes a class, `Uid2PublisherClient`, that has a function to determine if a token refresh is needed. + +The following examples show how you could first check if the token can be refreshed and then check if refresh is needed, using one of these SDKs. If it's time to refresh, you can then call the refresh function to refresh the token. + + + + +1. Determine if the identity can be refreshed (that is, the refresh token hasn't expired): + + ```java + if (identity == null || !identity.isRefreshable()) { we must no longer use this identity (for example, remove this identity from the user's session) } + ``` + +1. Determine if a refresh is needed: + + ```java + if (identity.isDueForRefresh()) {..} + ``` + + + + +1. Determine if the identity can be refreshed (that is, the refresh token hasn't expired): + + ```py + if not identity or not identity.is_refreshable(): # we must no longer use this identity (for example, remove this identity from the user's session) + ``` + +1. Determine if a refresh is needed: + + ```py + if identity.is_due_for_refresh()): + ``` + + + + +Before using the code example, check the prerequisites and notes for the language you're using. For details, refer to the doc for the applicable SDK: + +- [SDK for Java, Usage for Publishers, Basic Usage Server-Side Integration section](../sdks/sdk-ref-java.md#basic-usage-server-side-integration) +- [SDK for Python, Usage for Publishers, Server-Side Integration section](../sdks/sdk-ref-python.md#server-side-integration) + ## FAQs There are some frequently asked questions relating to token refresh: see [FAQs for Publishers](../getting-started/gs-faqs.md#faqs-for-publishers).