node-strava / node-strava-v3

API wrapper for Strava's v3 API, in Node
MIT License
356 stars 109 forks source link

401 unauthorized when trying to use user access token #75

Closed tympollack closed 5 years ago

tympollack commented 5 years ago

Running into an issue where when my user authenticates and I try to use the access token I get back, it's unauthorized.

using this to get access token

connectToStrava: function() {
                window.location = `https://www.strava.com/oauth/authorize?client_id=${stravaClientId}&redirect_uri=http://localhost:8080/table-list&response_type=code&scope=activity:read_all`
            },

then calling getAthlete

const getAthlete = async (accessToken) => {
    return await new Promise((resolve, reject) => {
        strava.athlete.get({access_token: accessToken}, (err, payload, limits) => {
            if (err) {
                console.error(err)
                reject(err)
            } else {
                resolve(payload)
            }
        })
    })
}

This code functions if I use the access token from my strava config, but since that resets, it's not reliable in production... or am I using this incorrectly?

markstos commented 5 years ago

Sorry, there's not developer bandwidth answer support requests here. You can try Stack Overflow.

tympollack commented 5 years ago

@markstos I was confused between the authorization code and access token and was missing an intermediate step. Got it working now. If you had actually read the issue you prob could have told me that.