Access is denied

48 views
Skip to first unread message

Donato Tesse

unread,
Oct 22, 2015, 2:40:08 PM10/22/15
to google-api-dotnet-client
Hi
I have a web site and I use this code to authenticate:

public static YouTubeService AuthenticateOauth()
{

string[] scopes = new string[] { YouTubeService.Scope.Youtube, // view and manage your YouTube account
YouTubeService.Scope.YoutubeForceSsl,
YouTubeService.Scope.Youtubepartner,
YouTubeService.Scope.YoutubepartnerChannelAudit,
YouTubeService.Scope.YoutubeReadonly,
YouTubeService.Scope.YoutubeUpload};

try
{
var folder = System.Web.HttpContext.Current.Server.MapPath(fileDataStore);
Log.LogWrite("err", "AuthenticateOauth", folder, "folder");
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = ClientId, ClientSecret = ClientSecret }
, scopes
, Username
, CancellationToken.None
, new FileDataStore(folder)).Result;

YouTubeService service = new YouTubeService(new YouTubeService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = Account,
});

return service;
}
catch (Exception ex)
{
Log.LogWrite("err", "AuthenticateOauth", ex.Message, ex.InnerException.Message);
return null;

}

return service;*/
}

But I get this error:
"Access is denied"

Why?
Thanks
Reply all
Reply to author
Forward
0 new messages