title: How to use authentication method to access Laravel API with swift?
body: <p>I'm developing iOS App
  I made POST API my self. 
  Now, when I press the button from iOS, I create a function to access APi and post value.
  I tried to input the value to test the API once with PostMan, but I got an error. <code>The page has expired due to inactivity.</code></p>
  
  <p>I understand that this error is because POST does not include <code>csrf_token</code>.</p>
  
  <p>If you use csrf_token on iOS to authenticate, what is the way to authenticate? Also, are there other authentication methods?</p>
  
  <p><strong>Swift Button function</strong></p>
  
  <pre><code>@IBAction func bookmarkBtn(_ sender: Any) {
      let user_id = defaultValues.string(forKey: "id")
  
      let urlString = "http://127.0.0.1:8000/store/favorite"
  
      let request = NSMutableURLRequest(url: URL(string: urlString)!)
  
      request.httpMethod = "POST"
      request.addValue("application/json", forHTTPHeaderField: "Content-Type")
  
  
  
      let params:[String:Any] = [
          "user_id": user_id,
          "store_id" : store_id,
      ]
  
      do{
          request.httpBody = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
  
          let task:URLSessionDataTask = URLSession.shared.dataTask(with: request as URLRequest, completionHandler: {(data,response,error) -&gt; Void in
              let resultData = String(data: data!, encoding: .utf8)!
              print("result:\(resultData)")
              print("response:\(response)")
  
          })
          task.resume()
      }catch{
          print("Error:\(error)")
          return
      }
  </code></pre>
  
  <p><strong>Laravel FavoriteController</strong></p>
  
  <pre><code>public function favorite(Request $request){
  
     Favorite::create(
          array(
              'user_id' =&gt; $request-&gt;user_id,
             'store_id' =&gt; $request-&gt;store_id,
          )
      );
      return ['Status' =&gt; 'Success'];
  }
  </code></pre>
  
  <p><strong>Laravel routes/web.php</strong></p>
  
  <pre><code>Route::post('/store/favorite', 'FavoriteController@favorite');
  </code></pre>