BluetoothAuthenticateDeviceEx function (bluetoothapis.h)

The BluetoothAuthenticateDeviceEx function sends an authentication request to a remote Bluetooth device. Additionally, this function allows for out-of-band data to be passed into the function call for the device being authenticated.

Note  This API is supported in Windows Vista SP2 and Windows 7.


DWORD BluetoothAuthenticateDeviceEx(
  [in, optional] HWND                        hwndParentIn,
  [in, optional] HANDLE                      hRadioIn,
  [in, out]      BLUETOOTH_DEVICE_INFO       *pbtdiInout,
  [in, optional] PBLUETOOTH_OOB_DATA_INFO    pbtOobData,
  [in]           AUTHENTICATION_REQUIREMENTS authenticationRequirement


[in, optional] hwndParentIn

The window to parent the authentication wizard. If NULL, the wizard will be parented off the desktop.

[in, optional] hRadioIn

A valid local radio handle or NULL. If NULL, then all radios will be tried. If any of the radios succeed, then the call will succeed.

[in, out] pbtdiInout

A pointer to a BLUETOOTH_DEVICE_INFO structure describing the device being authenticated.

[in, optional] pbtOobData

Pointer to device specific out-of-band data to be provided with this API call. If NULL, then a UI is displayed to continue the authentication process. If not NULL, no UI is displayed.

Note  If a callback is registered using BluetoothRegisterForAuthenticationEx, then a UI will not be displayed.

[in] authenticationRequirement

An BLUETOOTH_AUTHENTICATION_REQUIREMENTS value that specifies the protection required for authentication.

Return value

Returns ERROR_SUCCESS upon successful completion; returns the following error codes upon failure:

Return code Description
The user aborted the operation.
The device structure specified in pbdti is invalid.
The device in pbtdi is already been marked as authenticated.


The BLUETOOTH_DEVICE_INFO structure specified by pbtdilInOut must contain the address of a device to authenticate. If the value of pbtOobData is not NULL, an attempt will be made to authenticate the remote device with the provided out-of-band data.

For all other types of authentication, the caller should register an authentication callback using BluetoothRegisterForAuthenticationEx and then respond to the relevant authentication method using BluetoothSendAuthenticationResponseEx.


In the following example code a device has been found and an authentication request is sent using BluetoothAuthenticateDeviceEx.

HRESULT status;

HRESULT WINAPI AuthenticateService(){

	status = BluetoothAuthenticateDeviceEx( NULL,
					        MITMProtectionNotRequired );

	if ( ERROR_INVALID_PARAMETER == status ) {
		// goto Cleanup;
		// ...
		// Take cleanup action here,
		// ...
// Wait for the Authentication callback to return before trying to unregister the handle
// Use an infinite timeout since the handle to the function that sets the event is being
// deleted

	if ( WAIT_FAILED == WaitForSingleObject(hEvent, INFINITE) ) {
        	status = GetLastError();
        	// goto Cleanup;
		// ...
		// Take cleanup action here,
		// ...

      return status;


Requirement Value
Minimum supported client Windows XP with SP2 [desktop apps only]
Minimum supported server None supported
Target Platform Windows
Header bluetoothapis.h (include Bthsdpdef.h, BluetoothAPIs.h)
Library Bthprops.lib
DLL bthprops.cpl

See also