Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using ondemand credentials #31

Closed
Jke-A opened this issue Jan 24, 2018 · 12 comments
Closed

Error when using ondemand credentials #31

Jke-A opened this issue Jan 24, 2018 · 12 comments

Comments

@Jke-A
Copy link

Jke-A commented Jan 24, 2018

Hi,

I'm trying to upload files to SharePoint using ondemand credentials:

var coreOptions = {
    siteUrl: '*hidden url*',
    folder: "SiteAssets/Scripts",
    flatten: false
};
var creds = {
    ondemand: "true"
};
gulp.task("upload-to-sp", function () {
    return gulp.src([
        "./app/**/*.js",
        "./app/**/*.css",
        "./app/**/*.html"])
        .pipe(spsave(coreOptions, creds));
});

However, when I run the task I get the following error:

[15:17:51] Starting 'upload-to-sp'...
[15:17:57] spsave: Error occured:
[15:17:57] spsave: Cookie array is empty
[15:17:57] spsave: Stack trace:
[15:17:57] spsave: Error: Cookie array is empty
    at OnDemand.saveAuthData (C:\Users\joaander\source\repos\ABB.PA.GlobalManagementSite\ABB.PA.GlobalManagementSite\node_modules\spsave\node_modules\node-sp-auth\lib\src\auth\resolvers\ondemand\OnDemand.js:104:19)

It worked a couple of days ago on a site collection on the same tenant. Electron is started but it closes quickly as if it is using cached credentials.

Any clues?

Thanks,
Joachim

@s-KaiNet
Copy link
Owner

Hi, is that online or on-premise?

@Jke-A
Copy link
Author

Jke-A commented Jan 24, 2018

It is online. The reason I started using on-demand credentials is that they use MFA. I tried reinstalling Electron but it didn't make any difference

@s-KaiNet
Copy link
Owner

s-KaiNet commented Jan 24, 2018

ok, try a few options:

  1. Even with MFA you can use username\password authentication. You should create a new app password. To do that:
    • In the top right corner in SharePoint click on profile -> My Account -> Manage security and privacy -> Additional security verification -> Update your phone numbers used for account security -> App Passwords (in the top)
    • create new app password
    • use your login name as username and app password as password for spsave
  2. Another option is to delete a file at path c:\Users\[your logged in user]\AppData\Roaming\spauth\ondemand\ which corresponds to your site url and try to run the process again.

For now I'm not sure what is the cause for this behavior, probably some kind of cookie expiration issue.

@Jke-A
Copy link
Author

Jke-A commented Jan 24, 2018

The first one I'm unfortunately not able to change due to policies on the customer's O365.
I tried the other option but it didn't make a difference as there were no files related to the site I tried connecting to.

I tried some more and now I got another UnauthorizedAccessException instead. It might have to do with my permissions on the site. Is full control not enough to run spsave? It works on another site collection where I have full control.

@s-KaiNet
Copy link
Owner

When running in ondemand mode, it prints actual file path with credentials data in console. Try to delete those file and start from scratch.

@Jke-A
Copy link
Author

Jke-A commented Jan 24, 2018

I tried that but no luck. Still Unauthorized exception:

[16:45:29] spsave: Error occured:
[16:45:29] spsave: 403 - {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}}
[16:45:29] spsave: Stack trace:
[16:45:29] spsave: StatusCodeError: 403 - {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}}

The weird part is I never get to sign in electron.. It shows this window for ½ second then closes:
bild

@s-KaiNet
Copy link
Owner

What if you try to set below creds config:

{
    ondemand: true,
    force: true,
    persist: true
}

@Jke-A
Copy link
Author

Jke-A commented Jan 24, 2018

It made no difference. I tried uploading to the new site from another project with the same node packages and gulp files, and it worked from there. I'm guessing something broke when I installed the packages(?)

@s-KaiNet
Copy link
Owner

s-KaiNet commented Jan 24, 2018

I don't think so... however you can try to install all packages from scratch. Also check that your user has permissions, because the error message clearly says that you don't have them.

The first one I'm unfortunately not able to change due to policies on the customer's O365.

Does it mean you can't create a new app password?

@Jke-A
Copy link
Author

Jke-A commented Jan 24, 2018

I am signed on to the site in my web browser, so permissions shouldn't be a problem. Tried reinstalling the packages, but no luck.

Yes, I'm not able to create an app password. I don't have access to the "Additional security verification" link under Security & Privacy.

I will try to create a new project from scratch tomorrow and hopefully it works. Thank you for your help today. I'll post my progress tomorrow 👍

/Joachim

@Jke-A
Copy link
Author

Jke-A commented Jan 25, 2018

Hi again,

I started a new project and installed gulp and gulp-spsave and it works fine. No idea what's wrong with the old project, but I'm moving all the content to the new one.
Thanks for your help and for a great plugin!

@s-KaiNet
Copy link
Owner

Hi, thank you, glad to know the issue finally resolved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants