strava-datasource: Refresh token not found error

Hi,

This looks to be a great plugin but I am having trouble connecting to the Strava API.

I am running a grafana server locally in a docker container but I am getting the following error:

Refresh token not found, authorize datasource first

I have done the following:

  • Install the plugin in the docker container with the following command grafana-cli plugins install grafana-strava-datasource
  • Restart the docker container
  • Create a directory /var/lib/grafana/strava
  • Define an environment variable export GF_STRAVA_DS_DATA_PATH=/var/lib/grafana/strava/
  • Add a datasource specifying the Client ID and Client Secret from an app created in my Strava account
  • I get the following messages

image

Do you know how I can solve this issue please?

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 41 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Hey, I’m still getting errors trying to work with the strava datasource.

When I add it it says everything is fine, but when trying to use it I get: Error status: 401 Unauthorized With the following logs

logger=plugin.grafana-strava-datasource t=2022-09-12T09:49:48.67219754Z level=error msg="Strava API request error" error="Error status: 401 Unauthorized"
logger=context traceID=00000000000000000000000000000000 userId=2 orgId=1 uname=<redacted> t=2022-09-12T09:49:48.673140533Z level=error msg="Request Completed" method=POST path=/api/datasources/5/resources/strava-api status=500 remote_addr=10.1.0.41 time_ms=249 duration=249.390115ms size=76 referer="https://grafana.private/explore?left=%7B%22datasource%22% │

Looking in the logs when adding the data source i get the following:

logger=plugin.grafana-strava-datasource t=2022-09-12T09:46:44.184867085Z level=info msg="Starting background prefetcher"
logger=plugin.grafana-strava-datasource t=2022-09-12T09:46:44.196263286Z level=info msg="Cache has been reset" datasource=Strava
logger=plugin.grafana-strava-datasource t=2022-09-12T09:46:44.725947909Z level=error msg="Error fetching activities" error="error fetching activities: Error status: 401 Unauthorized"

But in the gui it reports as a success: image

I’m running on grafana version v9.1.2 (3c13120cde)

I finally made it work after deleting and recreating the datasource from the grafana UI

I changed a fallback for data directory, now if GF_STRAVA_DS_DATA_PATH is not set, files will be created in default OS cache directory (under strava-datasource subfolder). Hope, I will fix issues when token is writing into the file in the root directory. Changes were made in 22a87da1dd4f8b4a17d865e9dfb5d610e3fef1f0 and 7eaddba777394ecc13142befdc2f8a908736e803.

@yihong0618 Using refresh token from the application page might be a good idea if you’re using plugin only for your personal access. But in general, one Strava application can be used for accessing multiple users. In this case each user will have its own refresh token. This is why I went recommended way for Strava authentication. I think I can add support for specifying refresh token for access your own data only.

@bullboa the same issue as above - since you’re on the grafana.com domain, you have to configure strava app domain callback to match it, like

Screenshot from 2021-05-24 19-58-27