---
id: object/codeunit/1140
type: object
title: Codeunit 1140 "OAuth 2.0 Mgt."
summary: Codeunit 1140 "OAuth 2.0 Mgt." in Base Application (System.Security.Authentication). 15 public procedures, 2 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC24, BC27.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "27"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 8279a67affa82dbbf2346271b45f81aff1883c75f37c0434e0ad3453ecb9604b
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/System/OAuth/OAuth20Mgt.Codeunit.al
    title: src/Layers/W1/BaseApp/System/OAuth/OAuth20Mgt.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 1140
name: OAuth 2.0 Mgt.
namespace: System.Security.Authentication
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "27"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 44
  events: 2
  subscribers: 1
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 4
  called_by: 0
  implements: 0
---

# Codeunit 1140 "OAuth 2.0 Mgt."

> Codeunit 1140 "OAuth 2.0 Mgt." in Base Application (System.Security.Authentication). 15 public procedures, 2 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC24, BC27.

Base Application · System.Security.Authentication · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/System/OAuth/OAuth20Mgt.Codeunit.al) · facts from BC29

## Events published

- `OnBeforeCheckEncryption(var IsHandled: Boolean)` (integration)
- `OnBeforeGetServiceUrlForAuthorizationURL(var ServiceUrl: Text; OAuth20Setup: Record "OAuth 2.0 Setup")` (integration)

## Event subscriptions

- OnAfterGetCurrRecordPageEvent subscribes to Page "OAuth 2.0 Setup" OnAfterGetCurrRecordEvent

## Procedures

- `RequestAuthFromNotification(AuthNotification: Notification)`
- `GetAuthorizationURLAsSecretText(OAuth20Setup: Record "OAuth 2.0 Setup"; ClientID: Text): SecretText`
- `RequestAccessToken(var OAuth20Setup: Record "OAuth 2.0 Setup"; var MessageText: Text; AuthorizationCode: SecretText; ClientID: Text; ClientSecret: SecretText; var AccessToken: SecretText; var RefreshToken: SecretText): Boolean`: Request access token using application/json ContentType.
- `RequestAccessTokenWithGivenRequestJson(var OAuth20Setup: Record "OAuth 2.0 Setup"; RequestJson: Text; var MessageText: Text; AuthorizationCode: SecretText; ClientID: Text; ClientSecret: SecretText; var AccessToken: SecretText; var RefreshToken: SecretText): Boolean`: Request access token using given request json and application/json ContentType.
- `RequestAccessTokenWithContentType(var OAuth20Setup: Record "OAuth 2.0 Setup"; RequestJson: Text; var MessageText: Text; AuthorizationCode: SecretText; ClientID: Text; ClientSecret: SecretText; var AccessToken: SecretText; var RefreshToken: SecretText; UseUrlEncodedContentType: Boolean): Boolean`: Request access token using application/x-www-form-urlencoded ContentType if UseUrlEncodedContentType is set to true or application/json ContentType otherwise.
- `RefreshAccessToken(var OAuth20Setup: Record "OAuth 2.0 Setup"; var MessageText: Text; ClientID: Text; ClientSecret: SecretText; var AccessToken: SecretText; var RefreshToken: SecretText): Boolean`: Refreshes access token using application/json ContentType.
- `RefreshAccessTokenWithGivenRequestJson(var OAuth20Setup: Record "OAuth 2.0 Setup"; RequestJson: Text; var MessageText: Text; ClientID: Text; ClientSecret: SecretText; var AccessToken: SecretText; var RefreshToken: SecretText): Boolean`: Refreshes access token with given request json using application/json ContentType.
- `RefreshAccessTokenWithContentType(var OAuth20Setup: Record "OAuth 2.0 Setup"; RequestJson: Text; var MessageText: Text; ClientID: Text; ClientSecret: SecretText; var AccessToken: SecretText; var RefreshToken: SecretText; UseUrlEncodedContentType: Boolean): Boolean`: Refreshes access token using application/x-www-form-urlencoded ContentType if UseUrlEncodedContentType is set to true or application/json ContentType otherwise.
- `InvokeRequest(var OAuth20Setup: Record "OAuth 2.0 Setup"; RequestJson: Text; var ResponseJson: Text; var HttpError: Text; AccessToken: SecretText; RetryOnCredentialsFailure: Boolean): Boolean`
- `RequestAuthorizationCode(OAuth20Setup: Record "OAuth 2.0 Setup")`
- `RequestAndSaveAccessToken(var OAuth20Setup: Record "OAuth 2.0 Setup"; var MessageText: Text; AuthorizationCode: SecretText): Boolean`
- `RefreshAndSaveAccessToken(var OAuth20Setup: Record "OAuth 2.0 Setup"; var MessageText: Text): Boolean`
- `InvokeRequestBasic(var OAuth20Setup: Record "OAuth 2.0 Setup"; RequestJSON: Text; var ResponseJSON: Text; var HttpError: Text; RetryOnCredentialsFailure: Boolean): Boolean`
- `CheckEncryption()`
- `GetHttpStatusFromJsonResponse(JsonString: Text; var StatusCode: Integer; var StatusReason: Text; var StatusDetails: Text): Boolean`

Plus 26 local procedures.

## Triggers

OnRun

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 1266 "Cryptography Management"](../codeunit/1266.md) (1 call: `GenerateCodeChallenge → GenerateHashAsBase64String`)
- [Codeunit 4110 "Base64 Convert"](../codeunit/4110.md) (1 call: `GenerateRandomCodeVerifier → ToBase64`)
- [Codeunit 457 "Environment Information"](../codeunit/457.md) (1 call: `CheckEncryption → IsSaaS`)
- [Page 9905 "Data Encryption Management"](../page/9905.md) (1 call: `CheckEncryption → (object)`)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24, BC27

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "OAuth 2.0 Mgt.")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
