DEV Community

Discussion on: Headless WordPress with React

Collapse
 
khaledallen profile image
khaledallen

Do you have any recommendations on how to get started with authenticating Wordpress using a react front-end?

Collapse
 
jchiatt profile image
J.C. Hiatt

There's a couple of different ways to do it, but if you're going to be deploying a production application you'll probably want to look into oAuth or JWT:

wp-oauth.com/kb/authenticating-wit...

auth0.com/docs/cms/wordpress/jwt-a...

I haven't personally tackled these myself — I've only used Basic Auth so far. Would a tutorial on either of these be helpful?

Collapse
 
wunnle profile image
wunnle

A tutorial on how to authenticate for SPA's would be awesome indeed

Collapse
 
khaledallen profile image
khaledallen

A tutorial would be awesome! I have tried this with ember.js, but ran into a wall. I was hoping react would have more supporting material but in general it seems like a blindspot. I will check out the resources you've provided though and muddle my way through.

Thread Thread
 
jchiatt profile image
J.C. Hiatt

What specifically was the wall you ran into?

Thread Thread
 
khaledallen profile image
khaledallen

I was able to set up an authentication call using ember-simple-auth, but couldn't figure out how to send all the needed information to the Wordpress server. nonce, token, etc. Basically, all we could send was the login and the password.

We get a response from the server though, with this message: Missing OAuth parameters oauth_nonce, oauth_signature.

Just wasn't sure how to generate all that information. My understanding was that ember-simple-auth was supposed to handle it automatically. I tried writing code to generate those bits on my own, but it turned out to be a little over my head and I was concerned about the security concerns.

I could send you the actual code for the authenticator if you want.

Thanks for looking into this. I appreciate your time.

Thread Thread
 
jchiatt profile image
J.C. Hiatt

I'm not very familiar with Ember, but you can link me to the repo and I'll definitely at least take a look!

—J

Thread Thread
 
khaledallen profile image
khaledallen

Thanks! Here's the link: github.com/khaledallen/mindfishapp...