@classmethod<EOL><INDENT>def login_to_portal(cls,<EOL>domain=None,<EOL>portal_name=None,<EOL>user=None,<EOL>credential=None,<EOL>use_token=False,<EOL>portal_id=None,<EOL>get_devices=False,<EOL>debug=False):<DEDENT>
if domain is None:<EOL><INDENT>domain = _input("<STR_LIT>")<EOL><DEDENT>if portal_name is None:<EOL><INDENT>portal_name = _input("<STR_LIT>")<EOL><DEDENT>if user is None:<EOL><INDENT>user = _input("<STR_LIT>")<EOL><DEDENT>if None is credential:<EOL><INDENT>B = Portals(   domain=domain,<EOL>portal_name=portal_name,<EOL>user=user,<EOL>debug=debug<EOL>)<EOL>token = B.get_user_token()<EOL><DEDENT>elif not None is credential and not use_token:<EOL><INDENT>B = Portals(   domain=domain,<EOL>portal_name=portal_name,<EOL>user=user,<EOL>auth=credential,<EOL>debug=debug<EOL>)<EOL>token = B.get_user_token()<EOL><DEDENT>elif not None is credential and use_token:<EOL><INDENT>B = Portals(   domain=domain,<EOL>portal_name=portal_name,<EOL>user=user,<EOL>auth=credential,<EOL>use_token=use_token,<EOL>debug=debug<EOL>)<EOL>token = credential<EOL><DEDENT>if portal_id is None: <EOL><INDENT>B.get_portal_by_name(B.portal_name())<EOL><DEDENT>else:<EOL><INDENT>B.set_portal_id(portal_id)<EOL><DEDENT>if get_devices:<EOL><INDENT>B.map_aliases_to_device_objects()<EOL><DEDENT>return token, B<EOL>
A classmethod that returns a (token, Portals object) tuple.

This method can be interactive based on the input arguments.

Sets up the Portals object with all the member variables
it needs to make future api calls. It basically just calls 
Portals.get_portal_by_name(), but instead of returning a 
Portals object, it returns a Portals() object.

This is a convenience function that can be called at the 
time of instantiation.

Instantiate the Portals object with user/password authentication
then call this function. The resultant object will be a Portals
object that uses token authentication for all future calls 
instead of using user/password credentials.

Examples:
    # for interactive mode, get a password prompt, a token 
    # and a logged-in Portals object
    token, B = Portals.login_to_portal( domain=<domain>,
                                         portal_name=<portal>,
                                         user=<user/email>
    )

    # for non-interactive mode, passing in user password to 
    # get a token and a logged-in Portals object
    token, B = Portals.login_to_portal( domain=<domain>,
                                         portal_name=<portal>,
                                         user=<user/email>,
                                         credential=<password>
    )

    # for non-interactive mode, passing in token to get a 
    # logged-in Portals object
    token, B = Portals.login_to_portal( domain=<domain>,
                                         portal_name=<portal>,
                                         user=<user/email>,
                                         credential=<token>,
                                         use_token=True
    )

    # for non-interactive mode, passing in token and id 
    # to get a Portals object that doesn't need to make any 
    # Portals API calls. 
    token, B = Portals.login_to_portal( domain=<domain>,
                                         portal_name=<portal>,
                                         user=<user/email>,
                                         credential=<token>,
                                         use_token=True,
                                         portal_id=<portal_id>,
                                         portal_rid=<portal_rid>
    )