Migrate OAuth scripts to next-generation scripts
Different bindings are available to an OAuth script depending on the scripting engine version, legacy or next-generation.
To migrate legacy scripts to next-generation scripts:
-
Complete the steps to migrate common bindings, such as
httpclientandlogger, as described in Migrate to next-generation scripts.Review common bindings only available to next-generation scripts, such as
openidmandpolicy. Consider using them to simplify and improve your scripts. -
Update the script bindings that have changed for your OAuth script type by referring to the API and information in the following table.
Binding Used in API Next-generation change The
get/setScopemethods now accept/return aListinstead of aSet.The
Listformat makes it easier to retrieve values because you can access values directly without converting the return objects.The
addExtraData,addExtraJsonData, andsetPermissionsmethods now accept/return anObjectthat is converted to the relevant type, instead of aJsonValue.Attribute values are now returned as a
Listso that you can access values directly.You must now explicitly call
store()to persist changes to attribute values.requestedClaimsAccess the requested claims as a Map of List instead of Set objects.
requestedTypedClaimsNo longer available. Use
requestedClaimsinstead.scopesAccess the scopes as a
Listinstead of aSet.sessionThe legacy
sessionbinding is an instance of SSOToken. Methods includegetProperty,getTimeLeft,getMaxIdleTime, andgetTokenID.The next-generation
sessionbinding is an instance ofScriptedSession.tokenA
ExchangeableTokenScriptWrapperobject.
accessToken
| Legacy | Next-generation |
|---|---|
|
|
1 Add values directly to the addExtraData method.
2 Methods that accept/return JsonValues now use Object. The JavaScript engine converts the objects automatically to the appropriate type.
3 Methods that accept/return Sets now return Lists. You can access values more easily with the [] notation.
Learn more about the accessToken binding in Modify the access token.
identity
Use the identity binding to get data about the subject of the authorization request.
| Legacy | Next-generation |
|---|---|
|
|
1 The identity object is now a ScriptedIdentityScriptWrapper, which returns a List instead of a Set.
2 No need to convert objects by calling toArray()[1] or iterator().next(). Instead, you can access values directly, for example, identity.getAttributeValues("KEY")[0].
3 Adding or setting attributes on the identity object does not persist data.
4 You must explicitly persist changes by calling the store method.
Learn more about the identity binding in Access profile data.