/// <summary> /// Initialize underlying provider with relevant token information. /// </summary> /// <param name="oAuthTokens">Token instance.</param> /// <param name="requiredPermissions">List of required required permissions. public_profile and user_posts permissions will be used by default.</param> /// <returns>Success or failure.</returns> public bool Initialize(FacebookOAuthTokens oAuthTokens, FacebookPermissions requiredPermissions = FacebookPermissions.PublicProfile | FacebookPermissions.UserPosts) { if (oAuthTokens == null) { throw new ArgumentNullException(nameof(oAuthTokens)); } return(Initialize(oAuthTokens.AppId, requiredPermissions, oAuthTokens.WindowsStoreId)); }
/// <summary> /// Initialize underlying provider with relevant token information. /// </summary> /// <param name="appId">Application ID (Provided by Facebook developer site)</param> /// <param name="requiredPermissions">List of required required permissions. public_profile and user_posts permissions will be used by default.</param> /// <param name="windowsStoreId">Windows Store SID</param> /// <returns>Success or failure.</returns> public bool Initialize(string appId, FacebookPermissions requiredPermissions = FacebookPermissions.PublicProfile | FacebookPermissions.UserPosts, string windowsStoreId = null) { if (string.IsNullOrEmpty(appId)) { throw new ArgumentNullException(nameof(appId)); } if (string.IsNullOrEmpty(windowsStoreId)) { windowsStoreId = WindowsStoreId; } isInitialized = true; Provider.FBAppId = appId; Provider.WinAppId = windowsStoreId; // Permissions var permissionList = new List <string>(); foreach (FacebookPermissions value in Enum.GetValues(typeof(FacebookPermissions))) { if ((requiredPermissions & value) != 0) { var name = value.ToString(); var finalName = new StringBuilder(); foreach (var c in name) { if (char.IsUpper(c)) { if (finalName.Length > 0) { finalName.Append('_'); } finalName.Append(char.ToLower(c)); } else { finalName.Append(c); } } permissionList.Add(finalName.ToString()); } } permissions = new FBPermissions(permissionList); return(true); }