Server/python2/app_token.py [75:119]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if token is None:
            raise ValueError('empty appToken')

        if not token.startswith(VERSION_0):
            raise ValueError('unsupported version')

        data = util.compress_utils.decompress(base64.b64decode(token[VERSION_LENGTH:]))

        buf = io.BytesIO(data)

        signature_length = struct.unpack('>I', buf.read(4))[0]
        signature = buf.read(signature_length)

        app_id_length = struct.unpack('>I', buf.read(4))[0]
        app_id = buf.read(app_id_length).decode('utf-8')

        issue_timestamp = struct.unpack('>I', buf.read(4))[0]
        salt = struct.unpack('>I', buf.read(4))[0]
        timestamp = struct.unpack('>I', buf.read(4))[0]

        service = Service.unpack(buf)
        options = AppTokenOptions.unpack(buf)

        return AppToken(app_id, None, timestamp, issue_timestamp, salt, service, options, signature)

if __name__ == "__main__":
    # find appId in your RTC console (https://rtc.console.aliyun.com/#/manage/list)
    app_id = "replace_your_appId"
    # find appKey in your RTC console 
    app_key = "replace_your_appKey"
    # Token is valid for a maximum of 24 hours. This example uses 12 hours, adjust according to your needs.
    expired_ts = int(time.time()) + 12 * 60 * 60
    channel_id = 'replace_your_channelId'
    user_id = 'replace_your_userId'

    appToken = AppToken(app_id, app_key, expired_ts)

    # By default, all privileges are allowed. You can control audio/video/screen privileges individually as shown in the example below.
    # Please check(https://help.aliyun.com/document_detail/2689025.html) for more detail privilege informations. 

    # Example0: full privileges as default
    service = Service(channel_id, user_id)
    appToken.set_service(service)
    token = appToken.build()
    print(token)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



Server/python3/app_token.py [75:119]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if token is None:
            raise ValueError('empty appToken')

        if not token.startswith(VERSION_0):
            raise ValueError('unsupported version')

        data = util.compress_utils.decompress(base64.b64decode(token[VERSION_LENGTH:]))

        buf = io.BytesIO(data)

        signature_length = struct.unpack('>I', buf.read(4))[0]
        signature = buf.read(signature_length)

        app_id_length = struct.unpack('>I', buf.read(4))[0]
        app_id = buf.read(app_id_length).decode('utf-8')

        issue_timestamp = struct.unpack('>I', buf.read(4))[0]
        salt = struct.unpack('>I', buf.read(4))[0]
        timestamp = struct.unpack('>I', buf.read(4))[0]

        service = Service.unpack(buf)
        options = AppTokenOptions.unpack(buf)

        return AppToken(app_id, None, timestamp, issue_timestamp, salt, service, options, signature)

if __name__ == "__main__":
    # find appId in your RTC console (https://rtc.console.aliyun.com/#/manage/list)
    app_id = "replace_your_appId"
    # find appKey in your RTC console 
    app_key = "replace_your_appKey"
    # Token is valid for a maximum of 24 hours. This example uses 12 hours, adjust according to your needs.
    expired_ts = int(time.time()) + 12 * 60 * 60 
    channel_id = 'replace_your_channelId'
    user_id = 'replace_your_userId'

    appToken = AppToken(app_id, app_key, expired_ts)

    # By default, all privileges are allowed. You can control audio/video/screen privileges individually as shown in the example below.
    # Please check(https://help.aliyun.com/document_detail/2689025.html) for more detail privilege informations. 

    # Example0: full privileges as default
    service = Service(channel_id, user_id)
    appToken.set_service(service)
    token = appToken.build()
    print(token)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



