snapd_login()

snapd_login() — Client authorization

Functions

Includes

#include <snapd-glib/snapd-glib.h>

Description

To allow non-root users to authorize with snapd as D-Bus service called snapd-login-service is provided. This service uses Polkit to allow privileded users to install and remove snaps. snapd_login_sync() calls this service to get a SnapdAuthData that can be passed to a snapd client with snapd_client_set_auth_data().

Functions

snapd_login_sync ()

SnapdAuthData *
snapd_login_sync (const gchar *username,
                  const gchar *password,
                  const gchar *otp,
                  GCancellable *cancellable,
                  GError **error);

Log in to snapd and get authorization to install/remove snaps. This call contacts the snapd-login-service that will authenticate the user using Polkit and contact snapd on their behalf. If you are root, you can get this authentication directly from snapd using snapd_client_login_sync().

Parameters

username

usename to log in with.

 

password

password to log in with.

 

otp

response to one-time password challenge.

[allow-none]

cancellable

a GCancellable or NULL.

[allow-none]

error

GError location to store the error occurring, or NULL to ignore.

[allow-none]

Returns

a SnapdAuthData or NULL on error.

[transfer full]


snapd_login_async ()

void
snapd_login_async (const gchar *username,
                   const gchar *password,
                   const gchar *otp,
                   GCancellable *cancellable,
                   GAsyncReadyCallback callback,
                   gpointer user_data);

Asynchronously get authorization to install/remove snaps. See snapd_login_sync() for more information.

Parameters

username

usename to log in with.

 

password

password to log in with.

 

otp

response to one-time password challenge.

[allow-none]

cancellable

a GCancellable or NULL.

[allow-none]

callback

a GAsyncReadyCallback to call when the request is satisfied.

[scope async]

user_data

the data to pass to callback function.

[closure]

snapd_login_finish ()

SnapdAuthData *
snapd_login_finish (GAsyncResult *result,
                    GError **error);

Complete login started with snapd_login_async(). See snapd_login_sync() for more information.

Parameters

result

a GAsyncResult.

 

error

GError location to store the error occurring, or NULL to ignore.

[allow-none]

Returns

a SnapdAuthData or NULL on error.

[transfer full]

Types and Values