Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    AnotherGenericJim
    @AnotherGenericJim
    Hey everyone I am in an odd situation where I am on a SP 2013 on premise install with no app model turned on. I was hoping the node-sp-auth library might help with getting authorization for cross domain calls for localhost 3000 (not sure if it can accomplish this or not) as part of a react project in vs code. That being said I am also getting odd issues when I install that library. For instance it says readline is missing and when I try and change the path it then throws path binding errors. Was anyone able to get this library to work? If so will it solve for what I am attempting to do?
    this is the library I am referring to : https://www.npmjs.com/package/node-sp-auth
    Sergei Sergeev
    @s-KaiNet
    node-sp-auth is a module for nodejs, it can't be used in react application
    AnotherGenericJim
    @AnotherGenericJim
    I see
    I am pretty new to this whole js programming thing Sergei so I apologize if this dumb question. Isnt NodeJS just a bunch of libraries? What prevents it from being used with a react app? Again this is probably just an ignorance issue on my part. Thanks for being so quick to reply to my question.
    Sergei Sergeev
    @s-KaiNet
    no worries, that's the reason we have this chat - for the whole range of questions
    nodejs is an "environment" to run javascript on a server (i.e. in your operation system process), like .NET but for javascript
    when you run react app, it runs inside your browser, which is different from nodejs
    node-sp-auth uses some things from the underlying operation system, thus making it impossible to run in-browser (in react app for example)
    AnotherGenericJim
    @AnotherGenericJim
    Got it and a big thank you for the explanation. So what would I do to send a simple fetch call to Sharepoint 2013 with regards to cross domain rest calls? I saw that it uses a cookies to help with authentication but I am unsure how to approach grabbing it. I have tried just username, password, and domain in headers and that doesn't seem to get be passed a simple 401 and the no cross domain error. If you had a minute how would you potentially approach a scenario like this one? Again, I truly appreciate your insight and help.
    that get me passed not get be passed. Sorry about the typo.
    Sergei Sergeev
    @s-KaiNet
    just to be clear - you want to access SharePoint via rest api from your app running at localhost:3000, correct?
    AnotherGenericJim
    @AnotherGenericJim
    Yes Sergei that is what I am attempting.
    Sergei Sergeev
    @s-KaiNet

    tbh that's not a trivial question, it depends on type of authentication used by your SharePoint instance you're trying to reach out
    one option would be implementing the same type of authentication in your app, then enabling cors in SharePoint 2013 to be able to send cors request from one domain (your app) to SharePoint
    another option use server-side code with any kind of authentication (username and password) and perform all kind of operation from server
    the last option is provider-hosted app

    you can try to post your question on a forum https://sharepoint.stackexchange.com or https://techcommunity.microsoft.com/t5/SharePoint/bd-p/SharePoint_General

    AnotherGenericJim
    @AnotherGenericJim
    Ok I appreciate the help Sergei. Thanks!
    Andrew Koltyakov
    @koltyakov
    @AnotherGenericJim, localhost:3000 - so it's only during development time in CRA serve mode?
    did you try sp-rest-proxy? a bit old article yet shows the idea https://www.linkedin.com/pulse/getting-started-react-local-development-sharepoint-andrew-koltyakov/
    AnotherGenericJim
    @AnotherGenericJim
    Andrew Thanks for sharing I will on board that and give it a try. Appreciate you sharing.
    peni4142
    @peni4142
    Hi this is my second try for Gitter :) I using spsave for uploading to Sharepoint (O365). It returns Statuscode Error 500 (Internal Server Error). Does spsave create folders, if they don't exists?
    peni4142
    @peni4142
    Ok folder seems not to be the problem at all. Tried to upload into an existing folder
    peni4142
    @peni4142
    I getting following error: "500 - {"error":{"code":"-1, Microsoft.SharePoint.Client.UnknownError","message":{"lang":"de-DE","value":"Unbekannter Fehler."}}}", but I have no idea why
    Sergei Sergeev
    @s-KaiNet
    @peni4142 which kind of authentication do you use? username and password?
    I would suggest trying client id and client secret (aka add-in auth)
    use this wiki page to find out how to configure it https://github.com/s-KaiNet/node-sp-auth/wiki/SharePoint-Online-addin-only-authentication
    peni4142
    @peni4142
    using username and password at the moment.
    but maybe I have a problem with sharepoint, what is site, what is a folder. I am very new to sharepoint :D
    Sergei Sergeev
    @s-KaiNet
    Sometimes tenants admins disable auth with username and password, it might be the reason why it fails
    peni4142
    @peni4142
    I think authenfication is not that problem. I had already used bad password and get the error message, not authenficated
    yeah it works. I had a problem with understanding what is a folder and what is a site :D sorry for bothering you
    Andrew Koltyakov
    @koltyakov
    If it's SharePoint Online, custom script can be disabled by default. In case of custom scripts even being a site collection admin you are blocked in uploading a single JS/CSS, etc. Check this for details https://www.koskila.net/how-to-enable-custom-scripts-for-a-sharepoint-online-site-collection/
    peni4142
    @peni4142
    If I try to upload a file into a library (which contains folder) or set the "root"folder to a not existing entry of the library, I don't get an error, but I can't seet it in SharePoint
    Sergei Sergeev
    @s-KaiNet
    You should create a library with corresponding name first, SharePoint UI doesn't show all folders
    peni4142
    @peni4142
    but i writing an extension for vscode, which make it possible to upload folders to sharepoint. Therefor they have to follow some folder structure to get there stuff to the right place. But If they have a bad folder structure and try to upload their stuff to the wrong, not existing, place, I can't give them response
    Sergei Sergeev
    @s-KaiNet
    Have you seen spgo extension? https://marketplace.visualstudio.com/items?itemName=SiteGo.spgo probably you don't event need a custom one
    peni4142
    @peni4142
    I think in spsave is a check missing, which proofs there is an entry like the "roor" folder in the library
    Sergei Sergeev
    @s-KaiNet
    could you elaborate which kind of check is missing?
    peni4142
    @peni4142
    I will try
    peni4142
    @peni4142

    OK I don't know if the solution is a benefit for spsave, because I am a junior developer and new to sharepoint. But what I have:

    export async function getLibraryItems(libraryUrl: string, con: IConnection): Promise<string[]> {
    let apiUrl = libraryUrl.endsWith("/") ? libraryUrl + "_api/web/lists" : libraryUrl + "/_api/web/lists";
    let reqR = await sharepointGET(apiUrl, con);
    let arr: any[] = reqR.d.results;
    let result: string[] = [];
    for (let i: number = 0, l: number = arr.length; i < l; i++) {
    result.push(arr[i].Title);
    }
    return result;
    }
    In my case (I don't know if it is for every case), uploading is always to a library. So I will use the method above to check what folders? I have in the library and save the result in a static variable (don't call it every time) | staticVar[libraryUrl] = result;
    if the root folder is not in the variable I will do a doublecheck (maybe someone did an update) and in case the folder is not in it I throw an error.

    And sry for my bad writing :-)
    Ahmad Ali Saeed
    @ahmadali_saeed_twitter
    Hi there, I am trying to use node-sp-auth with a react app but I am getting Error: process.binding is not supported error so I am guessing that package doesn't support process binding with browser. Does anyone know any modern client side library that does the authentication with sharepoint 2013?
    Andrew Koltyakov
    @koltyakov
    @ahmadali_saeed_twitter you can't use node-sp-auth in browser. it's a library designed for Node.js. Check this possibility out: https://www.linkedin.com/pulse/getting-started-react-local-development-sharepoint-andrew-koltyakov/ - the proxy targets for the anvironment and node-sp-auth is under the hood to deal with auth
    Ahmad Ali Saeed
    @ahmadali_saeed_twitter
    @koltyakov that's a very good idea to create a server perform and the operations through that but there is no other way to perform auth with sharepoint 2013 on Client? I don't mind writing my own wrapper package but I couldn't find my information about how auth works in sharepoint on premises.
    Andrew Koltyakov
    @koltyakov
    Some things are just not feasible client-side due browsers security limitations.
    AnotherGenericJim
    @AnotherGenericJim
    Hey Andrew I tried your proxy thing on my work server and it connected through NTLM
    So my next question is do I now just call local host 8080 in one visual studio code browser and have a separate react one that fetches local host 8080?
    AnotherGenericJim
    @AnotherGenericJim
    If I use your nifty page set up that changes the link would that pull through to react
    Andrew Koltyakov
    @koltyakov
    It's not about the browser. What is used to serve React app locally, Webpack Dev Server? If a local web server supports API proxying it should be provided with a URL for the API endpoint (it's described in details in the mentined article). If a local web server doesn't support API proxying, in the client side application the requests should be routed correspondenly (when localhost, use proxy's address but not the same as the app is hosted on).
    Ahmad Ali Saeed
    @ahmadali_saeed_twitter
    that's what electron solves and allows us to connect remote service
    Andrew Koltyakov
    @koltyakov
    What's the connection with Electron? The question was about local development toolchain. With Electron, yep, you can use its backend (Node.js) process and node-sp-auth with a correct auth strategy. No nuances here.
    AnotherGenericJim
    @AnotherGenericJim
    Andrew I have it working and it solved my issue with local host. Thanks so much for making this as it is making development 100 times easier for me. Great job on a solid tool!
    Andrew Koltyakov
    @koltyakov
    Thanks @AnotherGenericJim! Glad it works for you.
    himyulian
    @himyulian
    Hello everyone, I'm sorry, I do not know if I can ask about PnPjs here?
    Andrew Koltyakov
    @koltyakov
    It's better asking here https://gitter.im/OfficeDev/PnP-JS-Core yet in this lobby many knows PnPjs as well.
    himyulian
    @himyulian

    I'm trying connect to SharePoint 2013 from Node

    import { sp } from "@pnp/sp";
    import { SPFetchClient } from "@pnp/nodejs";
    sp.setup({
        sp: {
            fetchClientFactory: () => {
                return new SPFetchClient("{site url}", "{client id}", "{client secret}");
            },
        },
    });
    sp.web.select("Title", "Description").get().then(w => {
        console.log(JSON.stringify(w, null, 4));
    });

    But i've got 401 Unauthorized

    Please help me understand the reason of the error.
    Response headers:
    изображение.png
    Request headers:
    изображение.png