> ## Documentation Index
> Fetch the complete documentation index at: https://vital-mintlify-83d472bf.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-83d472bf/epWSfqaE6WJSOETD/img/mfp-lock-diary.jpg?fit=max&auto=format&n=epWSfqaE6WJSOETD&q=85&s=d64b856f8f12da048a3a38ba1803e0a9" 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-83d472bf/epWSfqaE6WJSOETD/img/mfp-more.jpeg?fit=max&auto=format&n=epWSfqaE6WJSOETD&q=85&s=3eb66d5cbe513a8ecccd9b9568bed57e" 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-83d472bf/epWSfqaE6WJSOETD/img/mfp-settings.jpeg?fit=max&auto=format&n=epWSfqaE6WJSOETD&q=85&s=28fbc478384ad7f7474f725e30b497d6" 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-83d472bf/epWSfqaE6WJSOETD/img/mfp-diary-settings.jpeg?fit=max&auto=format&n=epWSfqaE6WJSOETD&q=85&s=8cd737c0a8431845a117cc76e5a058c0" 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-83d472bf/epWSfqaE6WJSOETD/img/mfp-diary-sharing.jpeg?fit=max&auto=format&n=epWSfqaE6WJSOETD&q=85&s=d4d4e2c0f49881e6cb6639c97aece842" 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-83d472bf/epWSfqaE6WJSOETD/img/mfp-link-search.png?fit=max&auto=format&n=epWSfqaE6WJSOETD&q=85&s=2ad3396fd757df06fe45a987151f6197" 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-83d472bf/epWSfqaE6WJSOETD/img/mfp-link-widget.png?fit=max&auto=format&n=epWSfqaE6WJSOETD&q=85&s=7260473cba5906716fa6c8d35cb6cbef" 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.
