title: Oauth1 iOS get data from API
body: <p>How to get data from API with Oauth1? I just tried like this but it did not work.</p>
  
  <pre><code>import UIKit
  import OAuthSwift
  
  class TestLogin: UIViewController {
  
  var oauthswift: OAuthSwift?
  final let urlString = "https://conversation.8villages.com/1.0/contents/articles"
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      self.doOAuth()
  }
  
  
  func doOAuth()
  {
  
  
      let oauthswift = OAuth1Swift(
          consumerKey:    "******",
          consumerSecret: "******",
          requestTokenUrl: "https://oauth.8villages.com/tokens/request-token",
          authorizeUrl:    "https://accounts.8villages.com/oauth/request-token",
          accessTokenUrl:  "https://accounts.8villages.com/oauth/access-token"
      )
  
  
      oauthswift.authorize(
          withCallbackURL: URL(string: "https://8villages.com")!,
          success: { credential, response, parameters in
              print(credential.oauthToken)
              print(credential.oauthTokenSecret)
              print(parameters["userId"])
      },
          failure: { error in
              print(error.localizedDescription)
      }             
      )
  }
  
  func getHandleURL () {
      let url = NSURL(string: urlString)
      URLSession.shared.dataTask(with: (url as? URL)!, completionHandler: { (data, response, error) -&gt; Void in
  
          if let jsonObj = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? NSDictionary {
  
              print(jsonObj!.value(forKey: "data"))
  
          }
  
      }).resume()
  }
  
  }
  </code></pre>
  
  <p>so, how must I do or I need a reference example get data from API with Oauth1? I just don't know how to start to build project with OAuth because I search in google, only tutorial OAuth for login with social media.</p>