Skip to content

/AWS1/IF_STS=>GETWEBIDENTITYTOKEN()

About GetWebIdentityToken

Returns a signed JSON Web Token (JWT) that represents the calling Amazon Web Services identity. The returned JWT can be used to authenticate with external services that support OIDC discovery. The token is signed by Amazon Web Services STS and can be publicly verified using the verification keys published at the issuer's JWKS endpoint.

Method Signature

METHODS /AWS1/IF_STS~GETWEBIDENTITYTOKEN
  IMPORTING
    !IT_AUDIENCE TYPE /AWS1/CL_STSWEBIDTOKAUDIENCE00=>TT_WEBIDTOKENAUDIENCELISTTYPE OPTIONAL
    !IV_DURATIONSECONDS TYPE /AWS1/STSWEBIDTOKENDURSECSTYPE OPTIONAL
    !IV_SIGNINGALGORITHM TYPE /AWS1/STSJWTALGORITHMTYPE OPTIONAL
    !IT_TAGS TYPE /AWS1/CL_STSTAG=>TT_TAGLISTTYPE OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_stsgetwebidtokenrsp
  RAISING
    /AWS1/CX_STSJWTPAYLOADSIZEEXEX
    /AWS1/CX_STSOUTBOUNDWEBIDFED00
    /AWS1/CX_STSSESSDURESCALATIO00
    /AWS1/CX_STSCLIENTEXC
    /AWS1/CX_STSSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

it_audience TYPE /AWS1/CL_STSWEBIDTOKAUDIENCE00=>TT_WEBIDTOKENAUDIENCELISTTYPE TT_WEBIDTOKENAUDIENCELISTTYPE

The intended recipient of the web identity token. This value populates the aud claim in the JWT and should identify the service or application that will validate and use the token. The external service should verify this claim to ensure the token was intended for their use.

iv_signingalgorithm TYPE /AWS1/STSJWTALGORITHMTYPE /AWS1/STSJWTALGORITHMTYPE

The cryptographic algorithm to use for signing the JSON Web Token (JWT). Valid values are RS256 (RSA with SHA-256) and ES384 (ECDSA using P-384 curve with SHA-384).

Optional arguments:

iv_durationseconds TYPE /AWS1/STSWEBIDTOKENDURSECSTYPE /AWS1/STSWEBIDTOKENDURSECSTYPE

The duration, in seconds, for which the JSON Web Token (JWT) will remain valid. The value can range from 60 seconds (1 minute) to 3600 seconds (1 hour). If not specified, the default duration is 300 seconds (5 minutes). The token is designed to be short-lived and should be used for proof of identity, then exchanged for credentials or short-lived tokens in the external service.

it_tags TYPE /AWS1/CL_STSTAG=>TT_TAGLISTTYPE TT_TAGLISTTYPE

An optional list of tags to include in the JSON Web Token (JWT). These tags are added as custom claims to the JWT and can be used by the downstream service for authorization decisions.

RETURNING

oo_output TYPE REF TO /aws1/cl_stsgetwebidtokenrsp /AWS1/CL_STSGETWEBIDTOKENRSP

Domain /AWS1/RT_ACCOUNT_ID
Primitive Type NUMC

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->getwebidentitytoken(
  it_audience = VALUE /aws1/cl_stswebidtokaudience00=>tt_webidtokenaudiencelisttype(
    ( new /aws1/cl_stswebidtokaudience00( |string| ) )
  )
  it_tags = VALUE /aws1/cl_ststag=>tt_taglisttype(
    (
      new /aws1/cl_ststag(
        iv_key = |string|
        iv_value = |string|
      )
    )
  )
  iv_durationseconds = 123
  iv_signingalgorithm = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_webidentitytokentype = lo_result->get_webidentitytoken( ).
  lv_datetype = lo_result->get_expiration( ).
ENDIF.