## EOAuth2Support EOAuth2Support — An interface for OAuth 2.0 support |

## Functions

gboolean | e_oauth2_support_get_access_token_sync ()
void | e_oauth2_support_get_access_token ()
gboolean | e_oauth2_support_get_access_token_finish ()

## Types and Values

struct | EOAuth2SupportInterface

## Includes

    #include <libebackend/libebackend.h>

## Description

Support for OAuth 2.0 access tokens is typically provided through dynamically loaded modules. The module will provide an extension class which implements the EOAuth2SupportInterface, which can be plugged into all appropriate EServerSideSource instances through `e_server_side_source_set_oauth2_support()`. Incoming requests for access tokens are then forwarded to the extension providing OAuth 2.0 support through `e_oauth2_support_get_access_token()`.

## Functions

### e_oauth2_support_get_access_token_sync ()

    gboolean
    e_oauth2_support_get_access_token_sync
                                   (EOAuth2Support *support,
                                    ESource *source,
                                    GCancellable *cancellable,
                                    gchar **out_access_token,
                                    gint *out_expires_in,
                                    GError **error);

Obtains the OAuth 2.0 access token for `source` along with its expiry in seconds from the current time (or 0 if unknown).

Free the returned access token with `g_free()` when finished with it. If an error occurs, the function will set `error` and return `FALSE`.

#### Parameters

support | an EOAuthSupport |
source | an ESource |
cancellable | optional GCancellable object, or `NULL` |
out_access_token | return location for the access token, or `NULL` |
out_expires_in | return location for the token expiry, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on failure

Since 3.8

### e_oauth2_support_get_access_token ()

    void
    e_oauth2_support_get_access_token (EOAuth2Support *support,
                                       ESource *source,
                                       GCancellable *cancellable,
                                       GAsyncReadyCallback callback,
                                       gpointer user_data);

Asynchronously obtains the OAuth 2.0 access token for `source` along with its expiry in seconds from the current time (or 0 if unknown).

When the operation is finished, `callback` will be called. You can then call `e_oauth2_support_get_access_token_finish()` to get the result of the operation.

#### Parameters

support | an EOAuth2Support |
source | an ESource |
cancellable | optional GCancellable object, or `NULL` |
callback | a GAsyncReadyCallback to call when the request is satisfied |
user_data | data to pass to the callback function |

Since 3.8

### e_oauth2_support_get_access_token_finish ()

    gboolean
    e_oauth2_support_get_access_token_finish
                                   (EOAuth2Support *support,
                                    GAsyncResult *result,
                                    gchar **out_access_token,
                                    gint *out_expires_in,
                                    GError **error);

Finishes the operation started with `e_oauth2_support_get_access_token()`.

Free the returned access token with `g_free()` when finished with it. If an error occurred, the function will set `error` and return `FALSE`.

#### Parameters

support | an EOAuth2Support |
result | a GAsyncResult |
out_access_token | return location for the access token, or `NULL` |
out_expires_in | return location for the token expiry, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on failure

Since 3.8

## Types and Values

### struct EOAuth2SupportInterface

    struct EOAuth2SupportInterface {
    	GTypeInterface parent_interface;

    	/* Synchronous I/O Methods */
    	gboolean (*get_access_token_sync)
    						(EOAuth2Support *support,
    						 ESource *source,
    						 GCancellable *cancellable,
    						 gchar **out_access_token,
    						 gint *out_expires_in,
    						 GError **error);

    	/* Asynchronous I/O Methods (all have defaults) */
    	void		(*get_access_token) (EOAuth2Support *support,
    						 ESource *source,
    						 GCancellable *cancellable,
    						 GAsyncReadyCallback callback,
    						 gpointer user_data);
    	gboolean (*get_access_token_finish)
    						(EOAuth2Support *support,
    						 GAsyncResult *result,
    						 gchar **out_access_token,
    						 gint *out_expires_in,
    						 GError **error);
    };

Since 3.8