I get the following exception while trying to download from CDN
PlayFabException: Must be logged in to call this method PlayFab.PlayFabClientAPI.GetContentDownloadUrl (PlayFab.ClientModels.GetContentDownloadUrlRequest request, System.Action`1 resultCallback, System.Action`1 errorCallback, System.Object customData, System.Collections.Generic.Dictionary`2 extraHeaders) (at Assets/PlayFabSDK/Client/PlayFabClientAPI.cs:409) PlayFabCDN.GetDownloadUrl (System.String key, System.Action`1 onComplete) (at Assets/Scripts/PlayFab/PlayFabCDN.cs:21) PlayFabCDN.DownloadFileFromCDN (System.String key) (at Assets/Scripts/PlayFab/PlayFabCDN.cs:13) WorldMaker.Start () (at Assets/Scripts/WorldMaker.cs:44)
Download code as below
Login and Download
I have been working on this for a couple of days now and can't get past it - any help would be very much appreciated. (The player seems to be logged in and their ID has been made in Playfab)
public static void Login() { if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId)) { /* Please change the titleId below to your own titleId from PlayFab Game Manager. If you have already set the value in the Editor Extensions, this can be skipped. */ PlayFabSettings.staticSettings.TitleId = "EB9E4"; } var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true }; PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure); } private static void OnLoginSuccess(LoginResult result) { Debug.Log("Congratulations, you made your first successful API call!"); } private static void OnLoginFailure(PlayFabError error) { Debug.LogWarning("Something went wrong with your first API call. :("); Debug.LogError("Here's some debug information:"); Debug.LogError(error.GenerateErrorReport()); }
public static void DownloadFileFromCDN(string key) { GetDownloadUrl(key, presignedUrl => { Console.WriteLine(""); }); } static void GetDownloadUrl(string key, Action<string> onComplete) { PlayFabClientAPI.GetContentDownloadUrl(new GetContentDownloadUrlRequest() { Key = key, ThruCDN = true }, result => onComplete(result.URL), error => Debug.LogError(error.GenerateErrorReport())); }