cloudinary / CloudinaryDotNet

Cloudinary DotNet library
MIT License
102 stars 68 forks source link

Authenticated assets are not accessed using token authentication #331

Open ashugthub opened 1 year ago

ashugthub commented 1 year ago

the following code is not working in cloudinary nuget package version -- 1.21.0. I am using .net core AuthToken t = new AuthToken("MyKey").Expiration(1514764800); string url = cloudinary.Api.Url .AuthToken(t) .Signed(true) .Type("authenticated") .BuildVideoTag("dog.mp4");

Type("authenticated") is not found in above code.

I am following https://cloudinary.com/documentation/control_access_to_media#delivering_token_based_authenticated_media_assets tutorial

Please also provide any sample for token based authentiv=cation .net core

epasos573 commented 1 year ago

Hi @ashugthub ,

The parameter for the authenticated is defined using the Action method of the Url class (see this reference). For example:

string KEY = "00112233FF99";
int DURATION = 300; //seconds
string ACL_ALL = "*";

var token = new AuthToken(KEY).Acl(ACL_ALL).Duration(DURATION);

string url = cloudinary.Api.Url
.AuthToken(token)
.Signed(true)
.Action("authenticated")
.BuildVideoTag("dog.mp4");

Console.WriteLine(url);

Hope this helps.