This cloud function verifies the access token passed in the 'Authorization' header. If the token is valid, it will return 'protected' member data. If the token is invalid, it will return a 401
unauthorized error back to the client.
š To use in Webflow, add the following code snippet:
In the global HEAD
section:
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.27.2/axios.min.js" integrity="sha512-odNmoc1XJy5x1TMVMdC7EMs3IVdItLPlCeL5vSUPN2llYKMJ2eByTTAIiiuqLg+GdNr9hF6z81p27DArRFKT7A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
In a custom code block section or BODY
of a page:
let memberstack = window.$memberstackDom;
let protectedData
memberstack.getCurrentMember().then(async ({ data: member }) => {
let accessToken = memberstack.getMemberCookie();
let { data } = await window.axios .get("https://{{ your napkin endpoint }} ", {
headers: { "Authorization": `Bearer ${accessToken}` },
})
protectedData = data
})
let profile = document.getElementByID('profile');
profile.innerHTML = protectedData.bio