Skip to content

Instantly share code, notes, and snippets.

@brad82
Created April 21, 2017 22:04
Show Gist options
  • Select an option

  • Save brad82/e84f26a157c949df62f38186bf960215 to your computer and use it in GitHub Desktop.

Select an option

Save brad82/e84f26a157c949df62f38186bf960215 to your computer and use it in GitHub Desktop.

Revisions

  1. Brad Morris created this gist Apr 21, 2017.
    47 changes: 47 additions & 0 deletions LoginViewController.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    //
    // ViewController.swift
    // Firstrate Football
    //
    // Created by Brad Morris on 21/04/2017.
    // Copyright © 2017 Brad Morris. All rights reserved.
    //

    import UIKit
    import Alamofire

    class ViewController: UIViewController {

    @IBOutlet weak var email: UITextField!
    @IBOutlet weak var password: UITextField!

    override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
    }


    @IBAction func loginButtonWasPressed(_ sender: Any) {
    self.attemptLogin(email: self.email.text!, password: self.password.text!)

    }

    func attemptLogin(email: String, password: String) {

    Alamofire.request("http://api.firstratefootball.com/v1/oauth/token", method: .post, parameters: [
    "grant_type": "password",
    "client_id": "1",
    "client_secret": "CFsncEJrRsawp1wEaMlaQxyLuNOg3UBWp8urmrZF",
    "username": email,
    "password": password
    ]).responseJSON { response in
    print(response.result.value)
    }

    }
    }