コード例 #1
0
ファイル: auth.py プロジェクト: jskitz/humanapi-python
 def get_authorize_url(self):
     """
     Retrieves temporary credentials from MapMyFitness, and returns the authorize URL to be
     thrown into the browers.
     
     """
     oauth = OAuth1(self.client_key, client_secret=self.client_secret,
                    callback_uri=self.callback_uri, signature_type='BODY')
     r = requests.post(url=self.temporary_credentials_url,
                       headers={'Content-Type': 'application/x-www-form-urlencoded',
                                'Accept': 'application/x-www-form-urlencoded'},
                       auth=oauth)
     self.temporary_credentials = urlparse.parse_qs(r.content)
     authorize_url = 'https://www.mapmyfitness.com/oauth/authorize/' \
                     '?oauth_token=%s&oauth_callback=%s' \
                     % (self.temporary_credentials['oauth_token'][0],
                        escape(self.callback_uri))
     return authorize_url
コード例 #2
0
ファイル: mapmyfitness.py プロジェクト: ehershey/utilities
    callback_uri = 'http://' + os.uname()[1] + ':12345/'

    oauth = OAuth1(client_key, client_secret=client_secret,
                   callback_uri=callback_uri, signature_type='BODY')

    r = requests.post(url=temporary_credentials_url,
                      headers={'Content-Type': 'application/x-www-form-urlencoded',
                               'Accept': 'application/x-www-form-urlencoded'},
                      auth=oauth)

    print(r.request.body)

    temporary_credentials = urlparse.parse_qs(r.content)

    authorize_url = 'https://www.mapmyfitness.com/oauth/authorize/?oauth_token=%s&oauth_callback=%s' % (
        temporary_credentials['oauth_token'][0], escape(callback_uri))

    print "sending to url"
    print "authorize_url: %s" % authorize_url

    if os.fork() == 0:
        webbrowser.open(authorize_url)
        exit()

    class AuthorizationHandler(BaseHTTPRequestHandler):

        def do_GET(self):
            self.send_response(200, 'OK')
            self.send_header('Content-Type', 'text/html')
            self.end_headers()
            self.wfile.write("Authorization received")
コード例 #3
0
    oauth_temp = OAuth1(
        config.client_credentials['oauth_token'][0],
        config.client_credentials['oauth_token_secret'][0],
        callback_uri=callback_uri,
        signature_type=config.web_redirection_flow_signature_type)
    r = post(url=config.temporary_credentials_url,
             headers={
                 'Content-Type': 'application/x-www-form-urlencoded', 'Accept':
                 'application/x-www-form-urlencoded'},
             auth=oauth_temp)
    temporary_credentials = urlparse.parse_qs(r.content)

    authorize_url = '{0}?oauth_token={1}&oauth_callback={2}'.format(
        config.user_authorization_url,
        temporary_credentials['oauth_token'][0],
        escape(callback_uri)
    )

    webbrowser.open(authorize_url)
    from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
    class AuthorizationHandler(BaseHTTPRequestHandler):
        def do_GET(self):
            self.send_response(200, 'OK')
            self.send_header('Content-Type', 'text/html')
            self.end_headers()
            self.server.path = self.path

    server_address = (urlparse.urlparse(callback_uri).hostname,
                      urlparse.urlparse(callback_uri).port)
    httpd = HTTPServer(server_address, AuthorizationHandler)
    httpd.handle_request()
コード例 #4
0
ファイル: mapmyfitness.py プロジェクト: reesmcivor/utilities
  temporary_credentials_url = 'http://api.mapmyfitness.com/3.1/oauth/request_token'

  callback_uri = 'http://' + os.uname()[1] + ':12345/'

  oauth = OAuth1(client_key, client_secret=client_secret, callback_uri=callback_uri, signature_type='BODY')

  r = requests.post(url=temporary_credentials_url,
      headers={'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': 'application/x-www-form-urlencoded'},
      auth=oauth)

  print(r.request.body)

  temporary_credentials = urlparse.parse_qs(r.content)

  authorize_url = 'https://www.mapmyfitness.com/oauth/authorize/?oauth_token=%s&oauth_callback=%s' % (temporary_credentials['oauth_token'][0], escape(callback_uri))

  print "sending to url"
  print "authorize_url: %s" % authorize_url

  if os.fork() == 0:
    webbrowser.open(authorize_url)
    exit()

  class AuthorizationHandler(BaseHTTPRequestHandler):
    def do_GET(self):
      self.send_response(200, 'OK')
      self.send_header('Content-Type', 'text/html')
      self.end_headers()
      self.wfile.write("Authorization received");
      self.server.path = self.path