当前位置: 首页>>代码示例>>Python>>正文


Python Client.authorization_url方法代码示例

本文整理汇总了Python中stravalib.client.Client.authorization_url方法的典型用法代码示例。如果您正苦于以下问题:Python Client.authorization_url方法的具体用法?Python Client.authorization_url怎么用?Python Client.authorization_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stravalib.client.Client的用法示例。


在下文中一共展示了Client.authorization_url方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: login

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
def login():
    params = {
        'client_id': CLIENT_ID,
        'redirect_uri': HOSTNAME + '/oauth_authorized/'
    }
    client = Client()
    url = client.authorization_url(**params)
    return redirect(url)
开发者ID:kimeberz,项目名称:fitnezz,代码行数:10,代码来源:app.py

示例2: auth

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
def auth():
    access_token = request.cookies.get('access_token')
    if access_token:
        # Success!
        return show_images_demo()
    else:
        client = Client()
        url = client.authorization_url(client_id=MY_STRAVA_CLIENT_ID, redirect_uri=DOMAIN + '/authorization')
        print("DEBUG: auth url :" + url)
        return redirect(url, code=302)
开发者ID:stuppie,项目名称:strava-pics,代码行数:12,代码来源:run.py

示例3: get

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
    def get(self):
        client = Client()
        authorize_url = client.authorization_url(client_id=conf.SV_CLIENT_ID, redirect_uri=conf.SV_AUTH_URL)


        template_values = {
            'url': authorize_url,
            'url_linktext': 'Connect with STAVA'
        }

        template = JINJA_ENVIRONMENT.get_template('index.html')
        self.response.write(template.render(template_values))
开发者ID:pdiazv,项目名称:localgears,代码行数:14,代码来源:main.py

示例4: Strava

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
class Strava(object):
    def __init__(self):
        self.client_id = current_app.config['STRAVA_CLIENT_ID']
        self.client_secret = current_app.config['STRAVA_CLIENT_SECRET']
        self.redirect_uri = url_for('strava.confirm_auth', _external=True)

        self.client = StravaClient()

        self._activity_type = 'ride'  # rides or runs
        self._activities = None

    @property
    def activity_type(self):
        return self._activity_type

    @activity_type.setter
    def activity_type(self, value):
        self._activity_type = value
        self._activities = None

    @property
    def athlete(self):
        return self.client.get_athlete()

    @property
    def activities(self):
        if not self._activities:
            # current_year = datetime.datetime.now().year
            # after = datetime.datetime(current_year - 2, 12, 25)
            self._activities = Activities(self.client.get_activities(), self.activity_type)
        return self._activities

    @classmethod
    def authorization_url(cls):
        self = cls()
        return self.client.authorization_url(client_id=self.client_id,
                                             redirect_uri=self.redirect_uri)

    def get_access_token(self, code):
        return self.client.exchange_code_for_token(client_id=self.client_id,
                                                   client_secret=self.client_secret,
                                                   code=code)

    @classmethod
    def athlete_by_code(cls, code):
        self = cls()
        self.client.access_token = self.get_access_token(code)
        return self.athlete

    @classmethod
    def athlete_by_token(cls, token):
        self = cls()
        self.client.access_token = token
        return self.athlete

    @classmethod
    def activities_by_token(cls, token):
        self = cls()
        self.client.access_token = token
        return self.activities

    @classmethod
    def by_token(cls, token):
        self = cls()
        self.client.access_token = token
        return self
开发者ID:rjames86,项目名称:fun-endpoints,代码行数:68,代码来源:strava.py

示例5: index

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
def index():
    """Home authentication page
    """ 
    conn = get_conn()
    client_id, client_secret = get_app_credentials(conn)
    client    = Client() # stravalib v3
    auth_link = client.authorization_url(client_id, REDIRECT_URI, scope=AUTH_SCOPE)
    title = "STRAVA buddies | Please log in to STRAVA"
    
    conn.close()
    return render_template("index.html", title=title, auth_link=auth_link,
                           tab="authenticate", examples=cached_athletes)
开发者ID:williaster,项目名称:strava_buddies,代码行数:14,代码来源:views.py

示例6: get

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
    def get(request):
        """ Request oauth via strava. """

        client = Client()

        return_uri = 'http://{}{}?start_date={}&end_date={}'.format(
            request.META['HTTP_HOST'],
            reverse_lazy('strava-authorized'),
            request.GET.get('start_date'),
            request.GET.get('end_date'),
        )
        authorize_url = client.authorization_url(
            client_id=settings.STRAVA_CLIENT_ID,
            redirect_uri=return_uri
        )
        return HttpResponseRedirect(authorize_url)
开发者ID:Gidgidonihah,项目名称:strava-fitness-challenge-leaderboard,代码行数:18,代码来源:views.py

示例7: StravaClient

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
    # get a strava client
    client = StravaClient()
    
    # if we haven't authorized yet, let's do it:
    if not token:
        # get token from strava
        client_id = cfg.get("StravaClient", "ClientId")
        client_secret = cfg.get("StravaClient", "ClientSecret")
        port = int(cfg.get("Application", "Port"))
        
        # setup webserver for authentication redirect
        httpd = http.server.HTTPServer(('127.0.0.1', port), AuthHandler)

        # The url to authorize from
        authorize_url = client.authorization_url(client_id=client_id, redirect_uri='http://localhost:{port}/authorized'.format(port=port), scope='view_private,write')
        # Open the url in your browser
        webbrowser.open(authorize_url, new=0, autoraise=True)

        # wait until you click the authorize link in the browser
        httpd.handle_request()
        code = httpd.code

        # Get the token
        token = client.exchange_code_for_token(client_id=client_id, client_secret=client_secret, code=code)

        # Now store that access token in the config
        cfg.set("UserAcct", "Token", token)
        with open("stravamng.cfg", "w") as cfg_file:
            cfg.write(cfg_file)
开发者ID:odontomachus,项目名称:stravalib_demo,代码行数:31,代码来源:stravamng.py

示例8: open

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
#                                               client_secret=MY_STRAVA_CLIENT_SECRET,
#                                               code=code)

from stravalib.client import Client

# test = np.load('/home/lgum/BitBucket/STRONZO/efforts.npz')

with open('/home/lgum/BitBucket/STRONZO/credentials.json', 'r') as credentials_file:
    credentials = json.load(credentials_file)


client = Client()

# authorize_url = client.authorization_url(client_id=10889082,
#                                redirect_uri='http://localhost:8282/authorized')
authorize_url = client.authorization_url(client_id=credentials['client_id'],
                               redirect_uri='http://localhost:8282/authorized')
# Have the user click the authorization URL, a 'code' param will be added to the redirect_uri
# .....
# Extract the code from your webapp response
# code = requests.get('code') # or whatever your framework does

access_token = str(credentials['access_token'])

# Now store that access token somewhere (a database?)
client.access_token = access_token
athlete = client.get_athlete()

# datetime.datetime(2005, 7, 14, 12, 30)
# start = datetime.datetime(2015, 10, 1, 0, 0)
# end = datetime.datetime(2015, 11, 20, 0, 0)
开发者ID:Lgum,项目名称:STRONZO,代码行数:33,代码来源:stronzo.py

示例9:

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
			if "code" in q:
				# Add the resulting code to global array
				# checked by the while loop below.
				code.extend(q["code"])
			self.send_response(200)
			self.end_headers()
			self.wfile.write("Thanks! Now go back to your terminal. :-)")
		else:
			self.send_error(404)

# Port doesn't matter so let the kernel pick one.
httpd = SocketServer.TCPServer(("", 0), Handler)
port = httpd.server_address[1]

authorize_url = client.authorization_url(
	client_id=APP["id"],
	redirect_uri="http://localhost:%d/authorized" % port,
	scope="write")

print "Now open the following URL and authorise this application."
print "Then Strava should send you to a localhost:%d URL handled by this script." % port
print "If that fails, rerun this script passing the code= value as an argument."
print
print authorize_url

# "code" gets updated once Strava calls us back.
while not code:
	httpd.handle_request()

access_token = client.exchange_code_for_token(
	client_id=APP["id"],
	client_secret=APP["client_secret"], code=code)
开发者ID:Wilm0r,项目名称:strava-mv,代码行数:34,代码来源:login.py

示例10: auth

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import authorization_url [as 别名]
def auth(request):
    client = Client()
    auth_link = client.authorization_url(5928,'https://elevation-challenge.herokuapp.com/auth_success/')
    return render(request, 'auth.html', {'leaderboard':get_leaderboard(), 'auth_link':auth_link})
开发者ID:wmorrill,项目名称:elevation,代码行数:6,代码来源:views.py


注:本文中的stravalib.client.Client.authorization_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。