Answers.Body: <p>I created a react native app with Craft CMS (still version 2.6) as backend using the Element API. But you're right, user authentication is not supported by the Element API. However, I created my own plugin to get user authenticated. I even create user and update their details through the app. </p>
  
  <p>But storing user sessions in React Native is another story. That has nothing to do with Craft or any other CMS system cause you can't get server session to React Native. You need to write your own session handler. I remember a good blog post about that topic: <a href="https://auth0.com/blog/adding-authentication-to-react-native-using-jwt/" rel="nofollow noreferrer">https://auth0.com/blog/adding-authentication-to-react-native-using-jwt/</a>. </p>
  
  <p>There also might be other solutions because this could be a little bit overkill.</p>
  
  <p>Hope this helps you as a first start.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-16T04:56:24.533Z
Answers.LastActivityDate: 2017-11-16T19:42:54.540Z
Answers.LastEditDate: 2017-11-16T19:42:54.540Z
Answers.UserDisplayName: Sven Jungnickel
Body: <p>I am hoping to create a React Site that uses Craft CMS and the Element API as a backend.  However, I know I will need to authenticate users and be posting data back into Craft which I believe the Element API doesn't support.  </p>
  
  <p>I was hoping someone might be able to talk me through if authenticating users is possible using a plugin and craft session service and if so what would be the general strategy given that this would be (at least in development) across two origins.  </p>
  
  <ol>
  <li>stage.project.com // craft cms w/ element api</li>
  <li>localhost:3000 // react development</li>
  </ol>
  
  <p>I haven't found any plugins out there that do just this, but it seems like it would be possible with a craft plugin.  Just wanted to confirm that this is possible and get a sense of how before investing the time.</p>
  
Tags: <craft-pro><authentication>
Title: Craft CMS Backing React FE using the element API
ThreadText: # Craft CMS Backing React FE using the element API
  
  (Asked by: username_0 on 2017-11-16)
  
  I am hoping to create a React Site that uses Craft CMS and the Element API as a backend. However, I know I will need to authenticate users and be posting data back into Craft which I believe the Element API doesn't support.
  
  I was hoping someone might be able to talk me through if authenticating users is possible using a plugin and craft session service and if so what would be the general strategy given that this would be (at least in development) across two origins.
  
  1. stage.project.com // craft cms w/ element api
  2. localhost:3000 // react development
  
  I haven't found any plugins out there that do just this, but it seems like it would be possible with a craft plugin. Just wanted to confirm that this is possible and get a sense of how before investing the time.
  
  **Tags:** craft-pro, authentication
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-11-16. Score: 3 | Accepted answer
  
  I created a react native app with Craft CMS (still version 2.6) as backend using the Element API. But you're right, user authentication is not supported by the Element API. However, I created my own plugin to get user authenticated. I even create user and update their details through the app.
  
  But storing user sessions in React Native is another story. That has nothing to do with Craft or any other CMS system cause you can't get server session to React Native. You need to write your own session handler. I remember a good blog post about that topic: <https://auth0.com/blog/adding-authentication-to-react-native-using-jwt/>.
  
  There also might be other solutions because this could be a little bit overkill.
  
  Hope this helps you as a first start.
  
  
  ---
  
  