Adding get_token helper script
1 files changed, 82 insertions(+), 0 deletions(-)

A => get_token.py
A => get_token.py +82 -0
@@ 0,0 1,82 @@ 
+''' Simple CLI tool to grab the FB access token needed
+    to get authorize with Tinder and receive an API
+    token.
+'''
+from __future__ import unicode_literals
+
+import getpass
+import argparse
+from tinder.utils import get_tinder_access_token
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument(
+        '-e', '--email',
+        dest='email_address',
+        default=None,
+        help='Facebook Email Address.',
+    )
+    parser.add_argument(
+        '-p', '--password',
+        dest='password',
+        default=None,
+        help='Facebook Password.',
+    )
+    parser.add_argument(
+        '-c', '--cookie-file',
+        dest='cookie_file',
+        default=None,
+        help='Cookie File.',
+    )
+    parser.add_argument(
+        '-a', '--ask',
+        dest='should_ask',
+        action='store_true',
+        default=False,
+        help='Signtal to prompt for credentials if not given on CLI.',
+    )
+    parser.add_argument(
+        '-d', '--die',
+        dest='should_die',
+        action='store_true',
+        default=False,
+        help=('If we run into an error, should we die '
+              'hard and print traceback? Useful for debugging'),
+    )
+    args = vars(parser.parse_args())
+
+    email = args.get('email_address')
+    password = args.get('password')
+    cookie_file = args.get('cookie_file')
+    should_ask = args.get('should_ask')
+    should_die = args.get('should_die')
+
+    if should_ask:
+        if email is None:
+            email = raw_input('Facebook Email Address? ')
+
+        if password is None:
+            password = getpass.getpass('Facebook Password? ')
+
+    if cookie_file is None:
+        cookie_file = '~/.fb_cookie_file'
+
+    try:
+        token = get_tinder_access_token(
+            username=email,
+            password=password,
+            cookie_file=cookie_file,
+        )
+    except ValueError as e:
+        if should_die:
+            raise
+        else:
+            print('Unable to get token: {0}'.format(e))
+            return
+
+    print(token)
+
+
+if __name__ == '__main__':
+    main()