c# - YouTube API service account returns 'forbidden 403' when inserting playlist item -


i'm writing simple application takes new uploads subscribed channels , adds them specified playlist. service account type used following code:

var certificate = new x509certificate2(certificatefilename, "notasecret", x509keystorageflags.exportable); var serviceinitializer = new serviceaccountcredential.initializer(serviceaccountemail) {         scopes = new[] { youtubeservice.scope.youtube } }; var serviceinitializerinstance = serviceinitializer.fromcertificate(certificate);  var credential = new serviceaccountcredential(serviceinitializerinstance); var youtubeservice = new youtubeservice(new baseclientservice.initializer {         httpclientinitializer = credential,         applicationname = applicationname }); 

i've succeeded in reading necessary information when try insert item playlist return error:

error: google.apis.requests.requesterror access forbidden. request may not authorized. [403]

errors [ message[access forbidden. request may not authorized.] location[ - ] reason[forbidden] domain[yo utube.common] ]

it seems core api general error according this link.

i've seen lot of samples , same. code is:

var newplaylistitemclone = new playlistitem(); newplaylistitem.snippet = new playlistitemsnippet(); newplaylistitem.snippet.playlistid = playlist.id; newplaylistitem.snippet.resourceid = new resourceid(); newplaylistitem.snippet.resourceid.videoid = existingplaylistitem.snippet.resourceid.videoid; newplaylistitem.snippet.resourceid.kind = existingplaylistitem.snippet.resourceid.kind;  await youtubeservice.playlistitems.insert(newplaylistitem, "snippet").executeasync(); 

where newplaylistitem item want insert , existingplaylistitem existing item channel uploads playlist. copy values , change playlist id.

also, when using api explorer on google developers documentation website works fine (web authorization used). in google developers console have api's enabled. maybe issue i'm lacking info required service account type? can me resolve issue?

here's github repository source code. error occurs on line 235 on request.

quoting official google youtube api documentation:

service accounts not work youtube data api calls because service accounts require associated youtube channel, , cannot associate new or existing channels service accounts. if use service account call youtube data api, api server returns error error type set unauthorized , reason set youtubesignuprequired.

please refer.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -