Authenticate CallbackAuthenticate Callback — Defining an Authenticate Callback |
The "authenticate" callback allows a program to prompt for an authentication token after receiving an indication from a DMAP server that authentication is required. Once it receives the authentication token, the callback should call dmap_connection_authenticate_message.
The following is a simple "authenticate" callback:
static void
authenticate_cb(DmapConnection *connection,
const char *name,
SoupSession *session,
SoupMessage *msg,
SoupAuth *auth,
gboolean retrying,
gpointer user_data)
{
char *username, password[BUFSIZ + 1];
g_object_get (connection, "username", &username, NULL);
fgets (password, BUFSIZ, stdin);
password[strlen(password) - 1] = 0x00; /* Remove newline. */
dmap_connection_authenticate_message(connection, session, msg, auth, password);
g_free(username);
}