protected void Page_Load(object sender, EventArgs e) { CheckPermissions(ModuleName.SOCIALMARKETING, PermissionsEnum.Read.ToString()); PageTitle.TitleText = GetString("sm.linkedin.account.companyaccesstoken"); PageTitle.ShowFullScreenButton = false; PageTitle.ShowCloseButton = false; if (Parameters == null) { ShowError(GetString("dialogs.badhashtext")); return; } var data = LinkedInProvider.GetLinkedInData(); if (data.UserDeniedAccess) { ShowError(GetString("sm.linkedin.account.msg.accesstokenrefused")); return; } var url = LinkedInHelper.GetPurifiedUrl(); if (!String.IsNullOrEmpty(data.Code)) { CompleteAuthorization(data, url); return; } BeginAuthorization(url); }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("socialnetworking.linkedin.accesstoken"); PageTitle.ShowFullScreenButton = false; PageTitle.ShowCloseButton = false; var data = LinkedInProvider.GetLinkedInData(); if (data.SettingsMissing) { lblStatus.Text = GetString("socialnetworking.linkedin.apisettingsmissing"); return; } var returnUrl = new Uri(URLHelper.GetAbsoluteUrl(LinkedInProvider.ACCESS_TOKEN_PAGE)); // User allowed access if (!String.IsNullOrEmpty(data.Code)) { // Authenticate and retrieve tokens if (LinkedInProvider.Authorize(data, returnUrl, out var token)) { // Return access token values and close the window var script = new StringBuilder("if(wopener.setAccessTokenToTextBox){ wopener.setAccessTokenToTextBox('") .AppendFormat("{0}', '{1}'); CloseDialog(); }}", data.EditorId, token.AccessToken); ScriptHelper.RegisterStartupScript(Page, typeof(string), "TokenScript", ScriptHelper.GetScript(script.ToString())); } else { // Error occurred while communicating with LinkedIn lblStatus.Text = GetString("socialnetworking.authorizationerror"); } return; } // User denied access if (data.UserDeniedAccess) { // Close the window var script = new StringBuilder("if(wopener.setAccessTokenToTextBox){ CloseDialog(); }"); ScriptHelper.RegisterStartupScript(Page, typeof(string), "TokenScript", ScriptHelper.GetScript(script.ToString())); return; } LinkedInProvider.OpenAuthorizationPage(data, returnUrl); }