YannickRe / vsts-sharepoint-alm

VSTS tasks that leverage the SharePoint ALM API's in a TFS/Team Services build or release definition
MIT License
1 stars 0 forks source link

Error when trying to use the extension #22

Open kpantos opened 2 years ago

kpantos commented 2 years ago

Hi, I'm trying to add a packaged application to my Sharepoint online instance using ADO. I've installed the extension from Marketplace and configured a Token based service connection. When calling the Add action

- task: SharePointALMCatalogScoped@2
  inputs:
    spSiteConnection: 'Sharepoint-Connection'
    useTenantCatalog: false
    action: 'Add'
    appFilePath: 'apackage.sppkg'
    overwriteExisting: true
    packageIdOut: 'VarPackageId'

I'm getting the following error:

2022-06-07T09:05:01.3147959Z ##[section]Starting: SharePointALMCatalogScoped
2022-06-07T09:05:01.3157589Z ==============================================================================
2022-06-07T09:05:01.3157989Z Task         : SharePoint ALM: Catalog Scoped Actions
2022-06-07T09:05:01.3158385Z Description  : ALM actions in scope of the SharePoint Tenant or Site App Catalog.
2022-06-07T09:05:01.3158697Z Version      : 2.0.12
2022-06-07T09:05:01.3158936Z Author       : Yannick Reekmans
2022-06-07T09:05:01.3159142Z Help         : 
2022-06-07T09:05:01.3159420Z ==============================================================================
2022-06-07T09:05:02.4081398Z Action: Add
2022-06-07T09:05:02.4082414Z SharePoint Site Connection: cd54abf2-f4ed-491d-b949-16f026e4c864
2022-06-07T09:05:02.4088874Z SharePoint Site Connection Type: Token
2022-06-07T09:05:02.4089364Z SharePoint Site Url: https://crm861539.sharepoint.com/sites/appcatalog/
2022-06-07T09:05:02.4089818Z Parsing Token
2022-06-07T09:05:02.4092324Z ClientId: ***
2022-06-07T09:05:02.4093229Z SharePoint App Package File Path: /home/vsts/work/1/s/SPFx/ducacode/sharepoint/solution/duca-issues.sppkg
2022-06-07T09:05:02.4093808Z Overwrite Existing Package: true
2022-06-07T09:05:02.4094159Z Package Id Variable: VarPackageId
2022-06-07T09:05:02.4389756Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4391600Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4392738Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4394043Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4395169Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4396224Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4397348Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4398395Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4399591Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4400721Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4401761Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4402887Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4404006Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4405053Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:02.4406223Z (node:2214) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-06-07T09:05:04.4558875Z ##[error]Error: GetDigestValue failed. StatusCode: 401. Result: Unauthorized.
2022-06-07T09:05:19.6020478Z ##[section]Finishing: SharePointALMCatalogScoped

Am I doing something wrong? Can you help?

Thanks,

YannickRe commented 2 years ago

Did you configure your Client ID and Secret like this? => https://github.com/s-KaiNet/node-sp-auth/wiki/SharePoint%20Online%20addin%20only%20authentication#configuration-required

Unfortunately, this extension is 4 years old and it has not been updated to use the new Azure based app registrations but only works with the SharePoint Add-in model. In terms of being a bit more supported, you might want to look into PnP Powershell as they have some commands that might help you achieve the same thing (albeit not as easy to use as a dedicated DevOps task).

kpantos commented 2 years ago

Thanks for the response @YannickRe

I'm already using the PnP cli commands to deploy the application from my devops pipeline. The problem is that these commands require a username and a password - they do not work with a Service Principal. Is that the suggested way of automating the deployment of sharepoint SPFx applicaitons?

I've already tried creating an add-in as mentioned above but didn't work, I'm still getting a 401 - unauthorized.

YannickRe commented 2 years ago

You should be able to do this with Client ID and Certificate through both PnP Powershell and M365 CLI. Pretty sure I did that before.

I just went through those steps again, from the article I linked, and it works without issue in my case. Could you try with a new App Registration? It is important to do the permissions on the -admin url.

kpantos commented 2 years ago

I just created a new app registration and followed the instructions of the site to the letter but I'm still getting the same error when running the pipeline.

image

YannickRe commented 2 years ago

Now your config is different than last time. Now your are using https://x.sharepoint.com/ and last time it was https://x.sharepoint.com/sites/appcatalog

I tested it out with a clean setup, and it worked. There most be something wrong with your configuration. Provide me the following information please:

Also, as explained: these actions are 4 years old and unmaintained over the years. I'd recommend you look into PnP first.