# Thunkable integrating with google fit

**URL:** https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679
**Category:** Questions about Thunkable X
**Created:** [September 2, 2022, 7:14am UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679 "2022-09-02T07:14:13Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 2, 2022, 7:14am UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/1 "2022-09-02T07:14:13Z")

</div>

I would like to request the thunkable staff team to add a feature that data can be fetched from googlefit

---

<div class="post-metadata">

### Author: ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)
#### Post date: [September 2, 2022, 7:21am UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/2 "2022-09-02T07:21:50Z")

</div>

Thanks for the request @lolxdyt6950as - as wearables continue to grow in popularity this is something we’ll have to consider going forward.

In the meantime, do you know if Google Fit has an API?

If so, then you can pull this data into your Thunkable app today with our Web API component.

Hope that helps!

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 2, 2022, 7:25am UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/3 "2022-09-02T07:25:44Z")

</div>

Yes! Google Fit has APIs

Can you help me set these up?  
Here is the API info: [Android APIs &nbsp;|&nbsp; Google Fit &nbsp;|&nbsp; Google Developers](https://developers.google.com/fit/android)

If it works, then maybe a pedometer will be possible in thunkable, i think?

now what should i do here?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/2/3235240c8a48fd9ace448a9a330e42d7ef3f087f.png)

---

<div class="post-metadata">

### Author: ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)
#### Post date: [September 2, 2022, 7:44am UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/4 "2022-09-02T07:44:27Z")

</div>

If you’re new to using APIs the check out the Thunkable Academy

> [@Jokes API tutorial](https://community.thunkable.com/t/jokes-api-tutorial/1809369):
>
> Next up from the [Thunkable Academy](https://bit.ly/3IYpLug) - and just in time for the Weekend Design Challenge - we have this tutorial on how to use the iCanHazDadJoke API In the tutorial you will learn all about setting request headers as well as how to retrieve random jokes to inject a bit of humour into your next app development project. Take a look and if you have any questions just ask them in this topic!

There are several tutorials there to help you go from novice to advanced user in just a few steps!

Let us know how it goes!

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 2, 2022, 10:42am UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/5 "2022-09-02T10:42:22Z")

</div>

I can not find a link to connect with the web api  
Im stuck here. Help

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/8/a8775540e0853ff1f4d5e240637c84fcf9da5b06.png)

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 2, 2022, 1:59pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/6 "2022-09-02T13:59:12Z")

</div>

dang ok i found yet another way to integrate google fit

just have to decompile the app and put it in android studio  
then set it up as google intended lol

edit: no i have problems still  
new problem forum link: [Decompiling a app](https://community.thunkable.com/t/decompiling-a-app/2026274)

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [September 3, 2022, 12:11pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/7 "2022-09-03T12:11:23Z")

</div>

Using the web api would be much simpler than decompiling the app. Are you a traditional developer and using noCode as a bridge gapper?

What issues are you experiencing using the webAPI. Looks like you need to integrate OAuth from google. are you familiiar with doing that?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [September 3, 2022, 3:06pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/8 "2022-09-03T15:06:53Z")

</div>

Google Fit has REST API end pints which you can use. The API is as follows:

```auto
GET https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}/datasets/{datasetId}

```

Following is the explanation of the parameters:

- userId should be **me**
- dataSourceId you will need another API to find it out if you do not have it stored.
- datasetId is the start time and end time in the form of EPOCH using the format `startTime-endTime`.

To obtain the dataSourceId use the following API:

```auto
GET https://www.googleapis.com/fitness/v1/users/userId/dataSources

```

The user ID running the API should have authorization to the following (from Google Docs)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/d/fd45a68ed801906931caba3929a7dbb9978dd70d.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/9/6994b94a008816fb9b0a14b2d5ca65b4936628f1.png)

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 3, 2022, 3:22pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/9 "2022-09-03T15:22:31Z")

</div>

No, im not familier with web api…

2: no im not a traditional developer, i was just using thunkable cuz its easy and fast  
3: i dont know how to use webapi  
4: no im not

edit: muneer answered me and explained 🙂

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 3, 2022, 3:23pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/10 "2022-09-03T15:23:58Z")

</div>

thanks dude. your explaination was good but i am not understanding {datasetId}

- datasetId is the start time and end time in the form of EPOCH using the format `startTime-endTime`.
- How do i fetch the user id

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [September 3, 2022, 3:52pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/11 "2022-09-03T15:52:20Z")

</div>

You need an access token. You can do this in a variety of ways.

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 3, 2022, 3:57pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/12 "2022-09-03T15:57:55Z")

</div>

how will i get a access token?

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [September 3, 2022, 4:00pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/13 "2022-09-03T16:00:40Z")

</div>

It’s quite a bit of setup. Atm, you need a supporting website which can be hosted on your Firebase instance.

If you’re interested in learning, I offer paid coaching sessions to bring you up to speed quickly! 🙂

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 3, 2022, 4:04pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/14 "2022-09-03T16:04:39Z")

</div>

i cant afford paid courses ☹

maybe now i have to figure it out

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [September 3, 2022, 5:20pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/15 "2022-09-03T17:20:49Z")

</div>

> [@lolxdyt6950as](#):
>
> but i am not understanding {datasetId}

An Epoch is a time represented in the number of milliseconds since 1970

The time I stared this response the Epoch was  
1662225491628

Google require that in nanoseconds so add 000 to it.

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 3, 2022, 5:37pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/16 "2022-09-03T17:37:00Z")

</div>

and how to get the datasourceId?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [September 3, 2022, 7:03pm UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/17 "2022-09-03T19:03:40Z")

</div>

> [@lolxdyt6950as](#):
>
> get the datasourceId?

See my message, you need to use the other API that I explained in my answer.

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 4, 2022, 5:27am UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/18 "2022-09-04T05:27:14Z")

</div>

now i have use these api to check:

- userID: me
- datasourceId: unable to fetch
- datasetID: 000

this is what returned:  
{  
“error”: {  
“code”: 401,  
“message”: “Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See [https://developers.google.com/identity/sign-in/web/devconsole-project.](https://developers.google.com/identity/sign-in/web/devconsole-project.)”,  
“errors”: [  
{  
“message”: “Login Required.”,  
“domain”: “global”,  
“reason”: “required”,  
“location”: “Authorization”,  
“locationType”: “header”  
}  
],  
“status”: “UNAUTHENTICATED”,  
“details”: [  
{  
“@type”: “[type.googleapis.com/google.rpc.ErrorInfo](http://type.googleapis.com/google.rpc.ErrorInfo)”,  
“reason”: “CREDENTIALS\_MISSING”,  
“domain”: “[googleapis.com](http://googleapis.com)”,  
“metadata”: {  
“method”: “google.android.fitness.v1.FitnessService.ListDataSources”,  
“service”: “[fitness.googleapis.com](http://fitness.googleapis.com)”  
}  
}  
]  
}  
}

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [September 4, 2022, 7:09am UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/19 "2022-09-04T07:09:35Z")

</div>

You need to select a `dataSourceId`.

You can use [Google Playground](https://developers.google.com/oauthplayground/) to define the **scope** which is required and to get OAuth credentials.

---

<div class="post-metadata">

### Author: ![lolxdyt6950as](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lolxdyt6950as](https://community.thunkable.com/u/lolxdyt6950as)
#### Post date: [September 4, 2022, 8:07am UTC](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679/20 "2022-09-04T08:07:44Z")

</div>

i got the oauth credentials but now what will i but in data source?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/0/c099a03adeb76ce2fbdb68b6d2cc1aa8f7ef2c3b.png)

[Next page](https://community.thunkable.com/t/thunkable-integrating-with-google-fit/2024679.md?page=2)
