# Auth Service Event Listener

**URL:** <https://devforum.zoom.us/t/auth-service-event-listener/87294>\
**Category:** Windows\
**Created:** [April 25, 2023, 3:00am UTC](https://devforum.zoom.us/t/auth-service-event-listener/87294 "2023-04-25T03:00:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dapto.kh](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dapto.kh/32/31683_2.png) [@dapto.kh](https://devforum.zoom.us/u/dapto.kh)\
**Post date:** [April 25, 2023, 3:00am UTC](https://devforum.zoom.us/t/auth-service-event-listener/87294/1 "2023-04-25T03:00:43Z")

</div>

I am following the sample code: “Initialize Zoom SDK and create authentication service” found here:  
[Windows SDK functions (zoom.us)](https://developers.zoom.us/docs/meeting-sdk/windows/use-meeting-sdk/windows-sdk-functions/)  
It states:  
// Call SetEvent to assign your IAuthServiceEvent listener  
yourAuthServiceEventListener = new YourAuthServiceEventListener();

 ![authListener](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/5/b/5bd58a59a75d14cdbc1de402f42b50328ab1dbe9.png)

Could you provide an example of a class inherited from IAuthServiceEvent and how to pass it into the SetEvent method?

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [April 25, 2023, 2:25pm UTC](https://devforum.zoom.us/t/auth-service-event-listener/87294/2 "2023-04-25T14:25:00Z")

</div>

> [@dapto.kh](#):
>
> IAuthServiceEvent

@dapto.kh ,

I would do something like this  
`AuthServiceEventListener* yourServiceEventListener= new AuthServiceEventListener();`

`authService.setEvent(yourServiceEventListener);`

You will probably have 2 additional files

**`AuthServiceEventListener.cpp`**

```auto
#include "AuthServiceEventListener.h"
#include <iostream>

using namespace std;

AuthServiceEventListener::AuthServiceEventListener()
{
    
}

void AuthServiceEventListener::onAuthenticationReturn(ZOOM_SDK_NAMESPACE::AuthResult ret) {
    if (ret == ZOOM_SDK_NAMESPACE::AuthResult::AUTHRET_JWTTOKENWRONG)
    {
        // SDK Auth call failed because the JWT token is invalid.
        cout << "Auth failed: JWT Token is invalid." << endl;
    }
    else if (ret == ZOOM_SDK_NAMESPACE::AuthResult::AUTHRET_SUCCESS)
    {
        // SDK Authenticated successfully
        cout << "Auth succeeded: JWT." << endl;
    }
    else 
        cout << "Auth failed: " << ret << endl;
}

void AuthServiceEventListener::onLoginReturnWithReason(LOGINSTATUS ret, IAccountInfo* pAccountInfo, LoginFailReason reason)
{
    cout << "onLoginReturnWithReason: " << reason << endl;

}

void AuthServiceEventListener::onLogout()
{
    cout << "onLogout" << endl;
}

void AuthServiceEventListener::onZoomIdentityExpired()
{
    cout << "onZoomIdentityExpired" << endl;
}

void AuthServiceEventListener::onZoomAuthIdentityExpired()
{
    cout << "onZoomAuthIdentityExpired" << endl;
}

void AuthServiceEventListener::onNotificationServiceStatus(SDKNotificationServiceStatus status)
{
    cout << "onNotificationServiceStatus: " << status << endl;
}

```

**`AuthServiceEventListener.h`**

```auto
#pragma once
#include <windows.h>
#include <auth_service_interface.h>

using namespace ZOOMSDK;
class AuthServiceEventListener :
    public IAuthServiceEvent
{
	
public:
	AuthServiceEventListener();

	/// \brief Authentication result callback.
	/// \param ret Authentication result value. For more details, see \link AuthResult \endlink enum.
	virtual void onAuthenticationReturn(AuthResult ret);

	/// \brief Callback of login result with fail reason.
	/// \param ret Login status. see \link LOGINSTATUS \endlink enum.
	/// \param pAccountInfo Valid when the ret is LOGINRET_SUCCESS. Otherwise NULL.
	/// \param reason Login fail reason. Valid when the ret is LOGIN_FAILED. Otherwise LoginFail_None. see \link LoginFailReason \endlink enum.
	virtual void onLoginReturnWithReason(LOGINSTATUS ret, IAccountInfo* pAccountInfo, LoginFailReason reason);

	/// \brief Logout result callback.
	virtual void onLogout();

	/// \brief Zoom identity has expired, please re-login or generate a new zoom access token via REST Api.
	virtual void onZoomIdentityExpired();

	/// \brief Zoom authentication identity will be expired in 10 minutes, please re-auth.
	virtual void onZoomAuthIdentityExpired();

	/// \brief Notification service status changed callback.
/// \param status The value of transfer meeting service. For more details, see \link SDKNotificationServiceStatus \endlink.
	virtual void onNotificationServiceStatus(SDKNotificationServiceStatus status);
};

```

---

<div class="post-metadata">

**Author:** ![dapto.kh](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dapto.kh/32/31683_2.png) [@dapto.kh](https://devforum.zoom.us/u/dapto.kh)\
**Post date:** [April 29, 2023, 1:19am UTC](https://devforum.zoom.us/t/auth-service-event-listener/87294/3 "2023-04-29T01:19:20Z")

</div>

This helps a lot. Thanks for your help Chun.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [May 29, 2023, 11:19am UTC](https://devforum.zoom.us/t/auth-service-event-listener/87294/4 "2023-05-29T11:19:53Z")

</div>

Closed on May 29, 2023, 11:19am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
