e-ms-oapxbc: Evolution-Data-Server Reference Manual

## e-ms-oapxbc e-ms-oapxbc — Interact with a locally running Microsoft OAuth2 broker service |

## Functions

EMsOapxbc * | e_ms_oapxbc_new_sync ()
JsonObject * | e_ms_oapxbc_get_accounts_sync ()
SoupCookie * | e_ms_oapxbc_acquire_prt_sso_cookie_sync ()

## Types and Values

#define | E_TYPE_MS_OAPXBC
| EMsOapxbc

## Object Hierarchy

        GObject
        ╰── EMsOapxbc

## Includes

    #include <libedataserver/libedataserver.h>

## Description

An EMsOapxbc object provides methods to interact with a locally running Microsoft OAuth2 broker service to implement the OAuth2 ms-oapxbc extension. This extension defines how broker clients can interact with the Microsoft OAuth2 endpoints. The key concept hereby are the PRT SSO cookies, which are acquired from a locally running broker service and are injected into the login UI and token refresh requests.

To get PRT SSO cookies, first call `e_ms_oapxbc_get_accounts_sync()` to get the users that are currently registered at the broker. Then, call `e_ms_oapxbc_acquire_prt_sso_cookie_sync()` with the account object that matches the user you want to get a PRT SSO cookie for. The PRT SSO cookies need to be injected either as cookie or as header into the login UI, as well as the token refresh requests. Note, that the PRT SSO cookies are short-lived with a minimal lifetime of 60 minutes.

## Functions

### e_ms_oapxbc_new_sync ()

    EMsOapxbc *
    e_ms_oapxbc_new_sync (const gchar *client_id,
                          const gchar *authority,
                          GCancellable *cancellable,
                          GError **error);

Synchronously create a new EMsOapxbc. This initiates the communication with a locally running Microsoft Identity broker service via D-Bus. In case the broker is not running, it is started. If no broker is registered, this function will fail (return `NULL`).

#### Parameters

client_id | a client ID of the broker client (UUID string). |
authority | an authority URL of the OAuth2 service |
cancellable | a GCancellable |
error | return location for a GError, or `NULL` |

#### Returns

a new EMsOapxbc.

[nullable][transfer full]

Since: 3.54

### e_ms_oapxbc_get_accounts_sync ()

    JsonObject *
    e_ms_oapxbc_get_accounts_sync (EMsOapxbc *self,
                                   GCancellable *cancellable,
                                   GError **error);

Synchronously calls `getAccounts()` D-Bus method on the Microsoft OAuth2 broker service and returns the result as a JsonObject.

The JsonObject contains the accounts that are currently registered at the broker, whereby the "accounts" node provides a JsonArray of account entries. Note, that the availability of the types and entries needs to be checked by the caller before accessing them. The accounts entries can be inspected e.g. for the "username" and "homeAccountId" fields. Then, one entry needs to be selected and passed as-is to `e_ms_oapxbc_acquire_prt_sso_cookie_sync()`.

#### Parameters

self | an EMsOapxbc |
cancellable | a GCancellable |
error | return location for a GError, or `NULL` |

#### Returns

the accounts, or `NULL` on error.

[nullable][transfer full]

Since: 3.54

### e_ms_oapxbc_acquire_prt_sso_cookie_sync ()

    SoupCookie *
    e_ms_oapxbc_acquire_prt_sso_cookie_sync
                                   (EMsOapxbc *self,
                                    JsonObject *account,
                                    const gchar *sso_url,
                                    JsonArray *scopes,
                                    const gchar *redirect_uri,
                                    GCancellable *cancellable,
                                    GError **error);

Synchronously calls `acquirePrtSsoCookie()` D-Bus method on the Microsoft OAuth2 broker service and converts the result into a new SoupCookie. The account object needs to be taken from the accounts list that is returned by `e_ms_oapxbc_get_accounts_sync()`. The SSO URL is the OAuth2 authentication endpoint. The scopes are the requested scopes for the OAuth2 service (usually only https://graph.microsoft.com/.default). The redirect URI is the OAuth2 service redirect URI.

#### Parameters

self | an EMsOapxbc |
account | an account returned from `e_ms_oapxbc_get_accounts_sync()` |
sso_url | an SSO URL to acquire the PRT SSO cookie for. |
scopes | array of scopes |
redirect_uri | redirect URI |
cancellable | a GCancellable |
error | return location for a GError, or `NULL` |

#### Returns

an acquired cookie, or `NULL` on error.

[nullable][transfer full]

Since: 3.54

## Types and Values

### E_TYPE_MS_OAPXBC

    #define E_TYPE_MS_OAPXBC e_ms_oapxbc_get_type ()

### EMsOapxbc

    typedef struct _EMsOapxbc EMsOapxbc;