def subscribe(self, channel_name, auth=None):
data = {'<STR_LIT>': channel_name}<EOL>if auth is None:<EOL><INDENT>if channel_name.startswith('<STR_LIT>'):<EOL><INDENT>data['<STR_LIT>'] = self._generate_presence_token(channel_name)<EOL>data['<STR_LIT>'] = json.dumps(self.user_data)<EOL><DEDENT>elif channel_name.startswith('<STR_LIT>'):<EOL><INDENT>data['<STR_LIT>'] = self._generate_auth_token(channel_name)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>data['<STR_LIT>'] = auth<EOL><DEDENT>self.connection.send_event('<STR_LIT>', data)<EOL>self.channels[channel_name] = Channel(channel_name, self.connection)<EOL>return self.channels[channel_name]<EOL>
Subscribe to a channel.

        :param str channel_name: The name of the channel to subscribe to.
        :param str auth: The token to use if authenticated externally.
        :rtype: pysher.Channel