Use Current User's Credentials for SharePoint Online SCOM C#


  • I am currently using my account's credentials to run some custom code in my SharePoint Online using CSOM in a windows form apps

    I am passing the credentials this way:

    ctx.Credentials = new SharePointOnlineCredentials("MyUserName", securePassword);

    This works just fine, but is there a way I could use current user's credentials instead, without hard-coding login and password?

    I've tried

    clientContext.Credentials = clientContext.Web.CurrentUser.Context.Credentials;

    But I get "error: (403) Forbidden" this way...

    • Edited by roma_victa Monday, February 27, 2017 12:17 PM
    Monday, February 27, 2017 12:14 PM

All replies