> ## Documentation Index
> Fetch the complete documentation index at: https://vital-mintlify-05adcdd3.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MyFitnessPal

> Connect MyFitnessPal accounts to Junction by configuring diary sharing with the required locked with key privacy setting.

## Connecting MyFitnessPal to Junction

You can now link MyFitnessPal accounts to Junction! You can do this with the Junction Link Widget or programmatically like other [password](/api-reference/link/link-password-provider) providers.

## Before Connecting

You can share your MyFitnessPal diary with Junction by locking your diary with a key.

* Go to [your diary settings](https://www.myfitnesspal.com/account/diary-settings) and click **locked with key**.<br />
  On mobile, head to *MyFitnessPal > More > Settings > Diary Settings > Diary Sharing*.

<Tabs>
  <Tab title="web">
    <Frame type="glass">
      <img src="https://mintcdn.com/vital-mintlify-05adcdd3/G7IuABKR1zalajdX/img/mfp-lock-diary.jpg?fit=max&auto=format&n=G7IuABKR1zalajdX&q=85&s=83eaa3952bd2726f61fe24cb5412484f" className="w-100 block mx-auto" width="1019" height="528" data-path="img/mfp-lock-diary.jpg" />
    </Frame>
  </Tab>

  <Tab title="mobile">
    <CardGroup>
      <Card>
        <img src="https://mintcdn.com/vital-mintlify-05adcdd3/G7IuABKR1zalajdX/img/mfp-more.jpeg?fit=max&auto=format&n=G7IuABKR1zalajdX&q=85&s=3847574132d1dc84978f1403c8127667" className="h-100 block mx-auto" width="1170" height="2532" data-path="img/mfp-more.jpeg" />
      </Card>

      <Card>
        <img src="https://mintcdn.com/vital-mintlify-05adcdd3/G7IuABKR1zalajdX/img/mfp-settings.jpeg?fit=max&auto=format&n=G7IuABKR1zalajdX&q=85&s=9d476097f35e81835f2455682b7d8f53" className="h-100 block mx-auto" width="1170" height="2532" data-path="img/mfp-settings.jpeg" />
      </Card>

      <Card>
        <img src="https://mintcdn.com/vital-mintlify-05adcdd3/G7IuABKR1zalajdX/img/mfp-diary-settings.jpeg?fit=max&auto=format&n=G7IuABKR1zalajdX&q=85&s=f21e693ae01493b1746a7a3cb0c784c0" className="h-100 block mx-auto" width="1170" height="2532" data-path="img/mfp-diary-settings.jpeg" />
      </Card>

      <Card>
        <img src="https://mintcdn.com/vital-mintlify-05adcdd3/G7IuABKR1zalajdX/img/mfp-diary-sharing.jpeg?fit=max&auto=format&n=G7IuABKR1zalajdX&q=85&s=b09aff9dfb2b7c62c9450182c3f66248" className="h-100 block mx-auto" width="1170" height="2532" data-path="img/mfp-diary-sharing.jpeg" />
      </Card>
    </CardGroup>
  </Tab>
</Tabs>

* Pick a key of your choice and save your changes.

You can now use the key and your MyFitnessPal username when linking with Junction via the widget or programmatically.

## Junction Widget

To connect your device with the *widget*, follow the link wizard and enter your username and key.

<CardGroup>
  <Frame type="glass">
    <img src="https://mintcdn.com/vital-mintlify-05adcdd3/G7IuABKR1zalajdX/img/mfp-link-search.png?fit=max&auto=format&n=G7IuABKR1zalajdX&q=85&s=da050a9442c8f5f961633bc786657ca6" className="w-full block mx-auto" width="471" height="703" data-path="img/mfp-link-search.png" />
  </Frame>

  <Frame type="glass">
    <img src="https://mintcdn.com/vital-mintlify-05adcdd3/G7IuABKR1zalajdX/img/mfp-link-widget.png?fit=max&auto=format&n=G7IuABKR1zalajdX&q=85&s=e7ca5590741ba0426ac06067b17863d8" className="w-full block mx-auto" width="471" height="703" data-path="img/mfp-link-widget.png" />
  </Frame>
</CardGroup>

Please note when linking programmatically that the **password** required in the payload
is the **locked key** you set in your [diary settings](https://www.myfitnesspal.com/account/diary-settings).

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
       --url {{BASE_URL}}/v2/link/provider/password/my_fitness_pal \
       --header 'Accept: application/json' \
       --header 'Content-Type: application/json' \
       --header 'x-vital-link-token: <VITAL-LINK-TOKEN>' \
       --data '
  {
       "username": "Your MyFitnessPal Username",
       "password": "Your Diary Key"
  }
  '
  ```

  ```python Python theme={null}
  user = client.Link.password_provider(
      link_token, provider, your_username, your_diary_key
  )
  ```

  ```typescript Javascript/Typescript theme={null}
  const user = await client.Link.connectProvider(
    linkToken,
    provider,
    yourUsername,
    yourDiaryKey
  );
  ```
</CodeGroup>

## Webhooks

On successful connection, you will receive:

* [Connection created](/webhooks/introduction#connection-created-stage) webhook.
* [Historical Meal](/webhooks/introduction#historical-data-backfill-stage) webhook, implying that the last *2 weeks* of data are fetched successfully.
* [Daily webhooks](/webhooks/introduction#incremental-data-stage) `daily.data.meal.created` and `daily.data.meal.updated` are issued, as new or more up-to-date data becomes available.
