I have some troubles with the Youtube Data API. I just want to rate a video. What I did:
Login the User with his google account and with necessary scopes. Then call the HTTP Request to rate the video
func setRating(objectID: String, completionHandler:(error:NSError?) -> Void ) {
let url = "https://www.googleapis.com/youtube/v3/videos/rate?id=(objectID)&rating=like&key=(self.kAPI)".convertToURL()
Alamofire.request(.POST, url, encoding: .JSON)
.validate()
.response { request, response, data, error in
if response == nil {
print("No Response: (error)")
completionHandler(error: error)
return
}
if error != nil {
print("There is an error: (error)")
ErrorHandler.sharedInstance.showYoutubeLoginError()
completionHandler(error: error)
return
}
completionHandler(error: nil)
}
}
I get the 401 Error with this request. The funny part is, that worked some time ago. But I don't know how and why. Everything is correct with the API Key. It works with GET Requests. Is there something that I'm missing?
Aucun commentaire:
Enregistrer un commentaire