none
Connect-PnPOnline The remote server returned an error: (403) Forbidden. RRS feed

  • Question

  • Hi All,
    I am trying to connect to SPO using PNP. I keep getting the error below:
    The remote server returned an error: (403) Forbidden.
    If I am trying to connect my dev-env its fine but my work env. is not working.
    I'm GCC High environment not commercial 

    Thanks


    Abenet

    Monday, January 27, 2020 4:59 PM

Answers

  • Hi,

    Do you have multifactor auth enabled on that account or with conditional access? If yes, try this 

    Connect-PnpOnline -Url https://yoursite.sharepoint.com -UseWebLogin
    ----------------------------------------------------------------------------------------------------------
    If you found this post helpful, please give it a "Helpful" vote. 
    Please remember to mark the replies as answers if they help.

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.


    • Marked as answer by NewET12345 Friday, February 7, 2020 6:00 PM
    Tuesday, January 28, 2020 7:22 AM
  • Hi Abenet,

    This happens when you use the -CurrentCredentials switch and your current user doesn’t have access to your site.

    The same error is also thrown if you try to connect to a sub site and the subsite doesn’t exist.

    As NM mentioned, try to use -UseWebLogin switch parameter, as this is required when you have multi-factor authentication (MFA) enabled in the tenant.

    Best regards,

    Julie


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by NewET12345 Friday, February 7, 2020 6:00 PM
    Tuesday, January 28, 2020 7:33 AM

All replies

  • Hi,

    Do you have multifactor auth enabled on that account or with conditional access? If yes, try this 

    Connect-PnpOnline -Url https://yoursite.sharepoint.com -UseWebLogin
    ----------------------------------------------------------------------------------------------------------
    If you found this post helpful, please give it a "Helpful" vote. 
    Please remember to mark the replies as answers if they help.

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.


    • Marked as answer by NewET12345 Friday, February 7, 2020 6:00 PM
    Tuesday, January 28, 2020 7:22 AM
  • Hi Abenet,

    This happens when you use the -CurrentCredentials switch and your current user doesn’t have access to your site.

    The same error is also thrown if you try to connect to a sub site and the subsite doesn’t exist.

    As NM mentioned, try to use -UseWebLogin switch parameter, as this is required when you have multi-factor authentication (MFA) enabled in the tenant.

    Best regards,

    Julie


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by NewET12345 Friday, February 7, 2020 6:00 PM
    Tuesday, January 28, 2020 7:33 AM
  • I can use the -UsewebLogin, the issue is when I am trying to loop through each site in my Tenant, it takes to long. Are there other options? Plus if you use the latest module, you don't have the option so.

    Thanks again


    Abenet

    Tuesday, January 28, 2020 5:37 PM
  • Hi Abenet,

    Whether you use Get-SPOSite to loop through each site collection in your tenant?

    If true, it depends on the site collection quantity and it’s by design.

    Best regards,

    Julie



    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, January 29, 2020 2:13 AM
  • Hi Abenet,

    Is there any progress on this issue?

    I am looking forward to your feedback if there is any update.

    Best regards,

    Julie



    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, February 3, 2020 1:07 AM
  • Openned ticket so waiting from MS. Work around is using the weblogin. If you update your pnp module to the latest, you will loose. 

    Abenet

    Monday, February 3, 2020 8:40 PM
  • Hi Abenet,

    Congratulations on solving this issue and thanks for sharing your solution.

    You could mark your solution as answer and it will do great help to those who meet the similar question in this forum.

    Thanks again for your contribution.

    Best regards,

    Julie


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, February 4, 2020 1:02 AM
  • The main issue is  TLS 1.0 or 1.1 enabled., as right now there is no fix. Waiting from MS team for updates. 

    Abenet

    Friday, February 7, 2020 6:00 PM