STRAVA API - 故事二(OAuth 2)

整理STRAVA API的OAuth 2機制,流程如下:

  1. oAuth2,[GET]授權取得exchange_token(時效30天)
    https://www.strava.com/oauth/authorize?client_id={0}&response_type=code&redirect_uri=http://localhost/exchange_token&approval_prompt=force&scope=activity:read
    登入Strava帳號+點授權鈕,COPY網址,截取code,即{2}
     
  2. [POST] 用code取得access_token{3}及refresh_token{4}
    https://www.strava.com/oauth/token?client_id={0}&client_secret={1}&code={2}&grant_type=authorization_code
     
  3. [GET] 取得JSON資料
    https://www.strava.com/api/v3/athlete/activities?access_token={3}&per_page=1
     
  4. [POST] 刷新access token(時效6小時)
    https://www.strava.com/oauth/token?client_id={0}&client_secret={1}&grant_type=refresh_token&refresh_token={4}