var scope = "https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/yt-analytics-monetary.readonly https://www.googleapis.com/auth/yt-analytics.readonly https://www.googleapis.com/auth/youtubepartner https://www.googleapis.com/auth/youtube.readonly"
var vc = GTMOAuth2ViewControllerTouch(scope: scope, clientID: clientID, clientSecret: clientSecret, keychainItemName: kKeyChainItemName, delegate: self, finishedSelector:Selector("authentication:finishedWithAuth:error:"))
In authentication(){
....
....
// On Success
service = GTLServiceYouTube()
service.authorizer = finishedWithAuth
// Channel is my Channel ID
var newQuery: GTLQueryYouTubeAnalytics = GTLQueryYouTubeAnalytics.queryForReportsQueryWithIds("channel==*****", startDate: "2014-10-15", endDate: "2014-10-16", metrics: "views,likes,shares,comments") as GTLQueryYouTubeAnalytics
var ticket1 = GTLServiceTicket()
ticket1 = service.executeQuery(newQuery, completionHandler: { (ticket: GTLServiceTicket!, object: AnyObject!, error: NSError!) -> Void in
println("Analytics: \(object) or \(error)")
})
}
This is my output:
Analytics: nil or Error Domain=com.google.GTLJSONRPCErrorDomain Code=404 "The operation couldn’t be completed. (Not Found)" UserInfo=0x***** {error=Not Found, NSLocalizedFailureReason=(Not Found), GTLStructuredError=GTLErrorObject 0x7f8e43ddc9b0: {message:"Not Found" data:[1] code:404}}
--------------------------------------------------------------------
What are we missing here? We ran a previous query for the YouTubeDataAPI and that worked well.
Any thoughts appreciated!
Thanks,
BW Team
The root cause of the issue was the Service used. The correct service to be used is:
service = GTLServiceYouTubeAnalytics()