class_docstr: A Mattermost communication channel.
class_docstr_tok: ["A","Mattermost","communication","channel","."]
docstr: Retrieve access token for mattermost user.
docstr_tok: ["Retrieve","access","token","for","mattermost","user","."]
code: def token_from_login(
      cls, url: Text, user: Text, password: Text
  ) -> Optional[Text]:
      """Retrieve access token for mattermost user."""
      data = {"login_id": user, "password": password}
      r = requests.post(url + "/users/login", data=json.dumps(data))
      if r.status_code == 200:
          return r.headers["Token"]
      else:
          logger.error(
              f"Failed to login mattermost user {user}. Response: {r}"
          )
          return None
  
imports: import json
  import logging
  import requests
  from requests import Response
  from sanic import Blueprint, response
  from sanic.request import Request
  from typing import Text, Dict, Any, List, Callable, Awaitable, Optional
  from rasa.core.channels.channel import UserMessage, OutputChannel, InputChannel
  from sanic.response import HTTPResponse
label_desc: Use image node_id 2 for calling the MattermostBot obj's underlying member method code with example usage: obj.token_from_login(cls, url, user, password) and returns: r, None