Implemeting Notion OAuth2

Hey! I have tried everything now to implement the Oauth2 flow for Notion, but I always get this error. Anyone has any ideas what could cause it?
No description
16 Replies
Jakub Hašek
Jakub HašekOP2w ago
I also get this error on the client
No description
Aaron
Aaron2w ago
It is receiving an incorrect client_id and client_secret That's really the only reason I know of that notion will respond with that error code
Jakub Hašek
Jakub HašekOP2w ago
Could this be because they want it encoded in Base64 and BetterAuth doesn't do that?
Jakub Hašek
Jakub HašekOP2w ago
No description
Aaron
Aaron2w ago
better-auth should be doing it internally. If its not, then something is wrong about that.
Jakub Hašek
Jakub HašekOP2w ago
Not sure. I used Remix OAuth2 before and did not change anything apart from the callback URL as specified in the OAuth2 plugin here
Aaron
Aaron2w ago
I haven't used better-auth's generic oauth2 implementation so I can't offer more help than what I have already stated. So either better-auth isn't base64 encoding the id and secret or your id and secret are wrong
Blank
Blank2w ago
try adding { authentication: 'basic' } in the config
Jakub Hašek
Jakub HašekOP2w ago
Lifesaver! Now I have a email_is_missing error, but it looks like the flow went through. Thanks 🙏
Blank
Blank2w ago
email_is_missing means the oauth is not returning a email in data try checking the socpes
Jakub Hašek
Jakub HašekOP2w ago
I think it is because the request to api.notion.com/v1/users/me fails with a 40I. From the error it seems like Better-auth doesn't pass the authorization header when requesting, which Notion requires
Jakub Hašek
Jakub HašekOP2w ago
No description
Blank
Blank2w ago
ok try this it is the endpoint which returns user data?
Jakub Hašek
Jakub HašekOP2w ago
Notion API
Retrieve your token's bot user
Retrieves the bot User associated with the API token provided in the authorization header. The bot will have an owner field with information about the person who authorized the integration. Errors Each Public API endpoint can return several possible error codes. See the Error codes section of the St...
Blank
Blank2w ago
you can just implement your custom function if the normal one is not working getUserInfo(tokens) {...} access tokens, call the api, return data
Jakub Hašek
Jakub HašekOP2w ago
Thanks! WIll figure that out 🙌

Did you find this page helpful?