samedi 11 novembre 2017

Using Laravel Passport with iOS (Swift)

I am trying login in Swift (iOS) via based Laravel webservice. At Laravel side I am using passaport. When I tried login with postman, it is works. However I couldn't for Swift. Swift side like this:

    @IBAction func login(_ sender: Any) {
    let url = "http://mytest:8000/oauth/token"
    let myUrl = URL(string:url)

    let params = [
        "grant_type":"password",
        "client_id": "1",
        "client_secret": "W04TCZ55lIrDjaT71LOUTY0ABT1why0fyPpK8EtY",
        "username": email.text!,
        "password": password.text!,
        "scope":"*"]

    Alamofire.request(myUrl!, method: .post, parameters: params).validate(contentType: ["application/json"]).responseJSON { (response) in

        switch response.result{
        case .success(let data):
            let json = JSON(data)
            print(json)
        case .failure(let error):
            print("hata: \(error)")
        }
    }
}

succesful case is works but response of json =

{
 "message" : "The user credentials were incorrect.",
 "error" : "invalid_credentials"
}

Finally I can't login from iOS side. I want to use Laravel backend for Swift app. Anyone can help me?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2hmpwhU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire