Help creating a secure SharePoint 2013 online application (Office 365)

Hi All,

I am looking for help in accessing SharePoint 2013 online (office 365) libraries securely. I currently use a simple class to hold my office 365 credentials, but I am looking for a more secure way of getting the credentials from the user. The code I am using is shown below.  

The question is can I make this simple application more secure. Maybe instead of storing the credentials in a class file, requesting the username and password from the user.

This is my first SharePoint 2013 online application so I may have made obvious mistakes.

I hope you can help. Thanks.

CEStar

***************

CredentialManager.cs:


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace AuthenticationApplication1

{

    class CredentialManager

    {

         static public String LoginName = "Type_UserName";

         static public String Password = "Type_Password";

    }

}

**********************

using Microsoft.SharePoint.Client;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

usingSystem.Security;

namespace AuthenticationApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            var siteUrl = "https://mySite.sharepoint.com/sites/Development";

            var loginName = CredentialManager.LoginName;

            var password = CredentialManager.Password;

            varsecurePassword = newSecureString();

            password.ToCharArray().ToList().ForEach(c => securePassword.AppendChar(c));

            using (var context = new ClientContext(siteUrl))

            {

                context.Credentials = newSharePointOnlineCredentials(loginName, securePassword);

                var web = context.Web;

                var list = web.Lists.GetByTitle("Site Pages");

                var query = new CamlQuery();

                query.ViewXml = "<View />";

                var items = list.GetItems(query);

                context.Load(items, c => c.Include(li => li.File.Name));

                context.ExecuteQuery();

                foreach (var item in items)

                {

                    Console.WriteLine(item.File.Name);

                }

                Console.ReadLine();

            }

        }

    }

}



  • Edited by CEStar 1 hour 17 minutes ago
January 31st, 2014 5:50am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics