def stravaAuthentication(request): print('check') auth_res = strava_oauth2(client_id=MY_STRAVA_CLIENT_ID, client_secret=MY_STRAVA_CLIENT_SECRET) client = StravaIO(access_token=auth_res['access_token']) athlete = client.get_logged_in_athlete() athlete = athlete.to_dict() print(athlete) return HttpResponse("Athlete Authenticated: " + athlete['firstname'])
def get_new_token(): token = strava_oauth2() token = json.dumps(token) file_token = open("token.json", "w") file_token.write(token) file_token.close() return token
def authenticate(strava_client_id, strava_client_secret): """ :param strava_client_id: :param strava_client_secret: :return: """ response = strava_oauth2(client_id=strava_client_id, client_secret=strava_client_secret) access_token = response['access_token'] return access_token
def get_athlete(access_token=ACCESS_TOKEN): # If the token is stored as an environment variable it is not necessary # to pass it as an input parameters client = StravaIO(access_token=access_token) athlete = client.get_logged_in_athlete() if athlete is None: #You need to authorise the app if you have not done so, #or your access token has expired. oauth2 = strava_oauth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET_ID) client = StravaIO(access_token=oauth2['access_token']) athlete = client.get_logged_in_athlete() return athlete
def get_token(self, force_reauth=False): if not force_reauth: try: return self._data['strava']['_token'] except KeyError: logger.info("Token not found in config. Refreshing.") token = stravaio.strava_oauth2( client_id=self._data['strava']['client_id'], client_secret=self._data['strava']['client_secret']) self._data['strava']['_token'] = token self.save() return token
from stravaio import Athlete, StravaIO, Streams, strava_oauth2 from football_strava import SETTINGS resp = strava_oauth2(client_id=SETTINGS.strava_client_id, client_secret=SETTINGS.strava_client_secret) STRAVA_ACCESS_TOKEN = resp["access_token"] client = StravaIO(access_token=STRAVA_ACCESS_TOKEN) athlete: Athlete = client.get_logged_in_athlete() streams: Streams = client.get_activity_streams(4093691464, athlete_id=athlete.id) # Store streams locally (~/.stravadata/streams_<athlete_id>/streams_<id>.parquet) # as a .parquet file, that can be loaded later using gpd.read_parquet() streams.store_locally()
def getaccesstoken(): stravaio.strava_oauth2( client_id='61082', client_secret='ba97041b32cb047711da0321c9c85f3aef4db2f4')
from stravaio import strava_oauth2 from stravalib.client import Client get_ipython().run_line_magic('matplotlib', 'inline') import matplotlib import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[ ]: #login details for API STRAVA_CLIENT_ID = <id> STRAVA_CLIENT_SECRET = "<secret> client = strava_oauth2(client_id=STRAVA_CLIENT_ID, client_secret=STRAVA_CLIENT_SECRET) # In[ ]: #grab token by passing temp token access_token = client.get('access_token') client = Client(access_token=access_token) # In[ ]: #call all activities activities = client.get_activities(limit=1000)
from stravaio import strava_oauth2 import os import dotenv dotenv.load_dotenv() token = strava_oauth2() print(token)
import stravaio from stravaio import strava_oauth2 import requests from stravaio import StravaIO import bs4 as bs import google_streetview import google_streetview.api import math import os import shutil import cv2 import numpy as np import glob output = strava_oauth2(client_id='', client_secret='') # If the token is stored as an environment varible it is not neccessary # to pass it as an input parameters # ## Gathering user routes # In[2]: access_token = str(output["access_token"]) client = StravaIO(access_token=access_token) athlete = client.get_logged_in_athlete().to_dict() athlete_id = athlete["id"] endpoint = "https://www.strava.com/api/v3/athletes/" + str( athlete_id) + "/routes"
from stravaio import strava_oauth2 from stravaio import StravaIO from config import CLIENT_ID, CLIENT_SECRET from notion_api import NotionInterface token = strava_oauth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET) # Get Strava Data client = StravaIO(access_token=token["access_token"]) activities = client.get_logged_in_athlete_activities() # Upload information to Notion notion = NotionInterface() table = notion.create_activity_log_table() for activity in activities: notion.add_row_to_table(table, activity)
from stravaio import strava_oauth2 token = strava_oauth2(client_id="PUT_ID_HERE", client_secret="PUT_SECRET_HERE")