# Notion Integration

**URL:** <https://community.weweb.io/t/notion-integration/1662>\
**Category:** How do I?\
**Created:** [January 4, 2023, 4:03pm UTC](https://community.weweb.io/t/notion-integration/1662 "2023-01-04T16:03:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaobsh](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@shaobsh](https://community.weweb.io/u/shaobsh)\
**Post date:** [January 4, 2023, 4:03pm UTC](https://community.weweb.io/t/notion-integration/1662/1 "2023-01-04T16:03:36Z")

</div>

I’m looking into how I can integrate with Notion. I would like the app to allow users to integrate with their own notion accounts. They should be able to allow access to the contents on their notion pages.

I’ve been looking at creating a custom Zapier Integration with Notion to a weweb app. Viewed the Notion Weweb youtube live. But I’m not sure where to go about an integration for my users not for myself.

I’m at a point where I have setup supabase = supabasee auth for user registration and login.

Any direction or advice would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [January 4, 2023, 5:20pm UTC](https://community.weweb.io/t/notion-integration/1662/2 "2023-01-04T17:20:00Z")

</div>

Hi,  
what you are looking for is probably a public notion integration.  
You can read more about it in the [notion developers doc](https://developers.notion.com/docs#public-notion-integrations) to start understanding what you need.

---

<div class="post-metadata">

**Author:** ![shaobsh](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@shaobsh](https://community.weweb.io/u/shaobsh)\
**Post date:** [January 5, 2023, 11:23pm UTC](https://community.weweb.io/t/notion-integration/1662/3 "2023-01-05T23:23:59Z")

</div>

@dorilama Thanks for the reference. I’m getting to a point where I’m able to achieve authorization through the notion integration i setup using supabase provider login with notion. The challenge I’m having is, after the notion login page and notion page access selection, I’m redirected back to my weweb project dashboard, rather than the page of my app. How can I ensure that a user will be redirected to the intended page within the app I’m building without publishing the app yet?

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [January 6, 2023, 7:18am UTC](https://community.weweb.io/t/notion-integration/1662/4 "2023-01-06T07:18:04Z")

</div>

you will need to specify the right url for the redirect.  
before you publish you should know what the final url will be

---

<div class="post-metadata">

**Author:** ![shaobsh](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@shaobsh](https://community.weweb.io/u/shaobsh)\
**Post date:** [January 6, 2023, 7:00pm UTC](https://community.weweb.io/t/notion-integration/1662/5 "2023-01-06T19:00:56Z")

</div>

ok awesome! thanks @dorilama ! and last question (for now atleast)

I’ve been following this article: [https://www.indiehackers.com/post/how-to-create-a-public-notion-integration-abc4c75a8c](https://how-to-create-a-public-notion-integration)

The part where is says:

> Click on **Allow access** and you should be redirected to your `redirect_uri`.
> 
> If users allow access, they’ll also be redirected to your `redirect_uri` with a temporary authorization `code`. It will look something like this:

```auto
https://YOUR_REDIRECT_URL/?code=9ac813er-34ad-4ba9-a5a0-1246ee085f86&state=
|--- Your redirect URL --| |--- The temporary authorization code ---|

```

Where is the code and how can I store that in weweb to make requests with?

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [January 6, 2023, 7:28pm UTC](https://community.weweb.io/t/notion-integration/1662/6 "2023-01-06T19:28:06Z")

</div>

> [@shaobsh](#):
>
> ```auto
> https://YOUR_REDIRECT_URL/?code=9ac813er-34ad-4ba9-a5a0-1246ee085f86&state=
> |--- Your redirect URL --| |--- The temporary authorization code ---|
> 
> ```

As you can read in the example, the code is in the url.

You may want to redirect to an endpoint of your backend instead of a page on your frontend, otherwise the temporary code will be accessible to any script that runs on your page (eg. any third party script you load)

---

<div class="post-metadata">

**Author:** ![shaobsh](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@shaobsh](https://community.weweb.io/u/shaobsh)\
**Post date:** [January 9, 2023, 7:00pm UTC](https://community.weweb.io/t/notion-integration/1662/7 "2023-01-09T19:00:03Z")

</div>

i am currently redirecting to an endpoint of supabase.  
Though I am having trouble calling the Notion API with the access token Supabase receives.

On another thread I found this:

> This should be available in the session from the `onAuthStateChange` method, the property is called `provider_token` , so you can retrieve it like:
> 
> ```auto
> supabase.auth.onAuthStateChange((event, session) => {
> const providerToken = session?.provider_token;
> })
> 
> ```

Not sure how to retrieve this within weweb. Any suggestions?

---

<div class="post-metadata">

**Author:** ![shaobsh](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@shaobsh](https://community.weweb.io/u/shaobsh)\
**Post date:** [January 17, 2023, 2:26pm UTC](https://community.weweb.io/t/notion-integration/1662/8 "2023-01-17T14:26:54Z")

</div>

@dorilama any clue what I can do on the weweb side to use this method?

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [January 17, 2023, 3:06pm UTC](https://community.weweb.io/t/notion-integration/1662/9 "2023-01-17T15:06:00Z")

</div>

Hi, you can try to access the user session this way

`wwLib.wwPlugins.supabaseAuth.publicInstance.auth.session();`

 ![Capture d’écran 2023-01-17 à 16.02.46](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/d9c95a5c64e8f581d6cab3cf0958d68dbe81e42a.png)

You should be able to retrieve the current user session and then see the provider\_token. 🙂

---

<div class="post-metadata">

**Author:** ![shaobsh](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@shaobsh](https://community.weweb.io/u/shaobsh)\
**Post date:** [January 17, 2023, 9:03pm UTC](https://community.weweb.io/t/notion-integration/1662/10 "2023-01-17T21:03:21Z")

</div>

@Alexis Thanks Alexis! This did the trick! exactly what I needed. Would be great to get this folded into some of the documentation. Wasn’t sure that this method existed in the wwLib for supabase plugin.
