How to integrate Memberstack authentication with React Native using Vercel backend without getting Missing Authentication errors?
Absolutely losing my mind right now - essentially trying to hook up Memberstack as my login for my react native application. Yes yes I know, memberstack is not natively built for anything outside of web applications, but I use webflow for all my companies and thus, I want to use it for our official IOS App aswell. Issue is, I keep getting this draining "Missing Authentication" Error.
const response = await axios.post(
'https://api.memberstack.com/v2/members/login',
{ email, password },
{
headers: {
'X-API-Key': process.env.MEMBERSTACK_SECRET_KEY, // Use API key from .env
'Content-Type': 'application/json',
im running a backend vercel deployment to run the Memberstack API with the intention of verifying their email/password, thus logging them into the application. Is this even possible with the current functionalities of the Memberstack API? I know the admin api does a little short of this as it doesn't provide the password for security reasons. I really don't want to switch off from Memberstack for our app. This will be our first app that uses the Memberstack Stripe system aswell, so we're super excited.
Any help would really be appreciated. Will provide all code as needed 😞
Comments
7 comments
Hey Ryan,
https://api.memberstack.com/v2/members/login is not a valid endpoint. The admin API doesn't have any sort of login route.
Take this with a grain of salt because I'm not super familiar with native apps, but I think you're best chance will be implementing a web view for login.
If you're able to do that, you can login the member like it was any other website (via the webview), get the token, and then later use that token to identify the user.
The admin API (and NPM package) does have an endpoint / method used to verify member tokens.
Unfortunately that's really the best advice I have. Native apps is a space we know nothing about.
Here are the docs for verifying a member token via the admin APIhttps://developers.memberstack.com/admin-rest-api/verification
Thanks Tyler!
Im open to anything, im ripping my hair out right now.
Ill try my best - I will report back with the results.
POST
https://client.memberstack.com/auth/loginheaders you would want to include
ah actually do this...
make sure to put your public key there. Not the secret key
once I get the login response with the token, what would be the recommended approach to store and pass the token in my app to authenticate further requests? Should I store it in AsyncStorage or some other secure way?
Tyler Bell what about the sign in with google or linkedin ?
webview is the only option i think if we want all these options! right?
Hi Memberstack team,
I’m building a React Native app. I’d like to authenticate users via Memberstack, but the official SDK (@memberstack/dom) is browser-only.
I couldn’t find any login / session endpoints in the REST or admin packages. I tried everything I could. The above approach only works for members that logged in through the normal email flow. But social log in doesn’t work unfortunately (Google and LinkedIn)
Any guidance or docs you can share would be greatly appreciated.
Thanks!
Please sign in to leave a comment.