VSTS Extension - Token authentication error - azure-devops

My team and I are working on creating a VSTS extension that will work with VSTS/Azure DevOps in the cloud, but the following 500 error is being thrown when trying to do a REST request:
HostAuthorizationNotFound
Microsoft.VisualStudio.Services.DelegatedAuthorization.SessionTokenCreateException
Here's the code:
// Get an instance of the client
var client = RestClient.getClient();
client.getWorkItem(10343, ["System.Title"]).then(
function(workItem) {
console.log(JSON.stringify(workItem))
},
function () {console.log("test")}
);
Uninstalling and reinstalling the extension has no effect, which seems to be the solution for others who have encountered this problem, and the extension scope was updated to include work items.
Additionally, the personal access token generated for my account works with the VSTS CLI. I'm able to create and query for work items with no issues there.
The Microsoft documentations mentions manual token creation for programs such as C# console apps, but my impression is that this should not be needed when working with an extension.
Is there something token related that needs to be explicitly declared in code?

The solution ended up being the same as what others have posted about: uninstalling and reinstalling the extension. In this case this was something that we tried initially but did not do entirely correctly -- the reinstallation did not take full effect since all the steps weren't followed (an admin also needed to approve the republishing of the extension).
So if you get this error, rest assured that uninstalling and reinstalling should do the trick!
See the following link for more details: https://learn.microsoft.com/en-us/azure/devops/extend/get-started/node?view=vsts#install-your-extension

Related

firebase_functions/unauthenticated UNAUTHENTICATED Flutter firebase functions admin [duplicate]

Recently I added a couple of new callable firebase cloud functions to my mobile app. The thins is, once I deployed and tested my functions I was not able to invoke them failing with an UNAUTHENTICATED error. I re-deployed all my functions and still, the old ones can be invoked while the new one failed with UNAUTHENTICATED. I did some research and people were talking about the version of the Node. I upgraded the Node version but it did not work out. I upgraded the firebase-functions version and the firebase-admin version. No luck.
I tried to browse to the URL of one of the older callable cloud functions that I have deployed before and it was ok. Then I tried to browse to a newly deployed https callable firebase cloud function. I saw this message in my browser:
Your client does not have permission to get URL /function_name from this server.
Any ideas what is going on here?
Thanks
Ok, here is what I found.
According to this page: https://cloud.google.com/functions/docs/securing/managing-access-iam#allowing_unauthenticated_function_invocation
As of January 15, 2020, HTTP functions require authentication by
default. You can specify whether a function allows unauthenticated
invocation at or after deployment.
Here is what you do:
1- Browse to the link above
2- Find "Viewing users" section and click on the "Go to Google Cloud Console" button.
3- On the screen that opens, you will see a list of your deployed cloud functions.
Select the one that is throwing the UNAUTHENTICATED error.
Click the Add Member button that appears on the right pane.
4- Select Cloud Functions Invoker role
5- Type allusers inside the "New Members" box. Select allUsers or allAuthenticatedUsers (Try with both to see which one works for you)
6- Hit "Save"
You should be able to invoke your firebase https callable cloud function now, and the UNAUTHENTICATED error should be gone.
I was having the same problem and what worked for me, was as simple as changing the function's name in the file (and of course where it was called) and redeploying it, which automatically deleted the first one.
EDIT #1: I've just had the same problem again and this time, I didn't rename the function. I only deleted the function manually inside firebase and then I redeployed it. It also works.
EDIT #2: Once again I had the same problem. However, this time I couldn't fix it with the alternatives above. I had upgraded my firebase-tools and something on this new version (10.3.1) was conflicting. Until I figure out what is the problem, I just downgraded firebase-tools (following this: https://stackoverflow.com/a/57262942/14608654) to version 10.2.2 and the error vanished.
in my case, I write wrong function name in my Flutter app
final callable = _functions.httpsCallable('wrong function name in here');

Fetching packages works, but pushing results in access denied

I have set up a new nuget feed (company internal feed) and installing packages works without any isuues, but when I try to push a new version for a package, I get a 401 access denied.
What might be the problem?
Edit: To add some more context. I am using a MacOS machine, with a clear text password for the feed since encryption is not supported.
Solved by adding --valid-authentication-types basic in the source config.

How to fix 401 Unauthorized Private Github Package

I am trying to install a private Github package to a Gatsby project I'm working on that will get deployed to Netlify, but I am continuing to get a 401 Unauthorized...
When I add my token inline, or use my ~/.npmrc file it works and installs fine but doesn't work when I am using a local environment variable.
Here is my .npmrc file...
//npm.pkg.github.com/:_authToken=$NPM_TOKEN
#OWNER:registry=https://npm.pkg.github.com/OWNER
NOTE
I have also tried this with no luck -
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
#OWNER:registry=https://npm.pkg.github.com/OWNER
How do I get my environment variable to work inside my local project .npmrc file?
UPDATE
I managed to get it working locally by removing the extra the last / from github.com (shown below), but this still doesn't fix the error on the Netlify side.
- //npm.pkg.github.com/:_authToken=$NPM_TOKEN
+ //npm.pkg.github.com:_authToken=$NPM_TOKEN
Any help would be appreciated, thanks.
I got it working but I'm sure there's a better way...
The .npmrc has to be
To get it working locally -
//npm.pkg.github.com:_authToken=$READ_TOKEN
#OWNER:registry=https://npm.pkg.github.com/OWNER
However this returns a 401 unauthorised error on Netlify...
To Get it to work on Netlify -
//npm.pkg.github.com/:_authToken=${READ_TOKEN}
registry=https://npm.pkg.github.com/OWNER
However like-wise this doesn't work locally...
At the moment I'm having to switch them out manually depending on whether I'm working locally or using it in production but as I say I think there must be a better way to do that.

Powershell DSC: Run regular code in DSC

I have a DSC I am creating for web server configuration. My website will be using HTTPS, meaning that I have to have a certificate in a store. I don't see any modules designed to do this, so I was wondering how I could run regular Powershell functions in a DSC but keep the good parts of the DSC.
My workflow is as follows:
1 . Check if certificate exists
If cert doesn't exist in the store, add it.
If the cert does exist, grab the the Thumbprint to use in the xWeb xWebsite.BindingInfo.MSFT_xWebBindingInformation.CertificateThumbprint property.
As of now, I've got the code written to do the following actions, but I would still like to make use of the [DependsOn] functionality found in DSCs so I can handle any errors involved with creating/accessing the certificate.
Any help is greatly appreciated.
https://serverfault.com/a/638926/236470
Use Microsoft's xCertificate module (with the xPfxImport resource) for this purpose.
Full disclosure: I wrote the original version of this resource (it's open source in Microsoft's repo now and has since had other contributors).
To answer your original question, you would use the Script resource to run arbitrary code without creating your own resource.

New Version of Tweetinvi Creating some issues

before update am using tweetinvi 0.9.07 and it works fine when I update it with the latest version it will generate several errors which are in snapshots
Tweetinvi credentials has changed in version 0.9.9.x.
You can find the documentation regarding this here.
TwitterCredentials.SetCredentials has changed to Auth.SetUserCredentials.
TwitterCredentials.ExecuteOperationWithCredentials has changed to Auth.ExecuteOperationWithCredentials.
Also please note that Auth.ExecuteOperationWithCredentials uses the credentials defined by creds. You therefore do not need to call Auth.SetUserCredentials inside a lambda of ExecuteOperationWithCredentials.
Finally please note that you can now create credentials via the new TwitterCredentials(...).