
# 场景2：登录
#### 描述
可用华为云会议账号或App ID或登录华为云会议。创建会议等接口不支持在未登录状态下调用，若要使用完整的会议功能，必须先登录华为云会议。
![](https://support.huaweicloud.com/sdkreference-meeting/public_sys-resources/note_3.0-zh-cn.png)
在未登录状态下，只能加入已经创建的会议。
#### 业务流程
使用SDK登录时，先调用Login接口，然后处理回调函数OnLoginResult。
1. **接口调用**
   
   1. 组装数据结构HwmLoginInfo。
      1. 选择合适的登录类型。
      
      2. 根据登录类型给对应的变量赋值。
       
   
   2. 调用Login进行登录，第1步中的数据作为参数。
   
   
   
   
2. **处理回调函数**
   
   处理回调函数OnLoginResult。
   
   
 
#### 示例代码
```
/**
* 登录处理
*/
int demoLoginDlg::Login()
{
    int ret;
    //设置App ID登录参数
   /**
    *.此处省略第三方服务器做的数据转换，最后获取到nonce和signature
    */
    strncpy_s(loginParam.appIdAuthInfo.thirdUserId, GetUserId.c_str(), HWM_MAX_USER_ID_LEN);
    strncpy_s(loginParam.appIdAuthInfo.userName, GetUserName.c_str(), HWM_MAX_USER_NAME_LEN);
    strncpy_s(loginParam.appIdAuthInfo.signature, GetSignature().c_str(), HWM_MAX_SIGNATURE_LEN);
    strncpy_s(loginParam.appIdAuthInfo.nonce, GetNonce().c_str(), HWM_APPID_NONCE_LEN );
    strncpy_s(loginParam.appIdAuthInfo.email, GetEmail.c_str(), HWM_MAX_EMAIL_LEN);
    strncpy_s(loginParam.appIdAuthInfo.phoneNumber, GetPhoneNumber.c_str(), HWM_MAX_PHONE_NUM_LEN);
    loginParam.appIdAuthInfo.expireTime = 1598398920; // utc时间，单位s
    loginParam.authType = hwmsdkagent::HWM_AUTH_TYPE_APPID;
    //调用登录接口
    ret = hwmsdkagent::Login(&loginParam);
    return ret;
}
```
```
/**
* 登录接口回调
*/
void demoCallbackProc::OnLoginResult(hwmsdk::HwmErrCode ret, const char* msg)
{
    CString codeStr;
    codeStr.Format(_T("%d"), ret);
    string msgStr = CTools::UTF82MultiByte(msg);
    CString tips = _T("OnLoginResult code:") + codeStr + _T(", msg:") + CString(msgStr.c_str());
    AfxMessageBox(tips);
}
```
