401 on azure-devops-node-api with access token acquired from adal-node - azure-devops

This is an issue between adal-node and azure-devops-node-api.
After getting access token from adal-node, I apply it as API_TOKEN to call azure-devops-node-api's getWebApi, target api is azure devops(vsts)-https://dev.azure.com/{org}.
Unfortunatelly, it returns 401 error:
Error: Error: Failed request: (401)
at RestClient.
at Generator.next ()

Related

Hashicorp Vault: 400 Bad Request Accept header is missing

I have enabled jwt auth on my dev vault instance
vault auth enable jwt
Success! Enabled jwt auth method at: jwt/
However, when I try to configure the jwks_url for the jwt auth I get the following error
➜ vault write auth/jwt/config jwks_url="<jwks_url>"
Error writing data to auth/jwt/config: Error making API request.
URL: PUT http://127.0.0.1:8200/v1/auth/jwt/config
Code: 400. Errors:
* error checking jwks URL: fetching keys oidc: get keys failed: 400 Bad Request Accept header is missing
Any idea what might I be doing wrong?

Google API Client Error: the caller does not have permission

I'm trying to use the Google API Client to gain access to a Google Doc. I get the following error:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://docs.googleapis.com/v1/documents/1Dc82X_w8UsyZnJe5JEh4E0wNdfbw-_nhVWXwgEJ4HVg?alt=json returned "The caller does not have permission". Details: "The caller does not have permission">
The error comes up in the file extract_text.py, which I got from here: https://developers.google.com/docs/api/samples/extract-text
Specifically, the error shows up at this line when it's obtaining the document's ID:
doc = docs_service.documents().get(documentId=documentID).execute()
The error states that my request has invalid authentication credentials (https://cloud.google.com/asset-inventory/docs/faq). I have made sure that I setup the OAuth correctly.

"Access is denied due to invalid credentials" REST API error. How to solve?

I followed the documentation here: and here: Trying to integrate to a Personality Insights service via Android Java.
However, after the app runs, and using the correct username and password as mentioned in the guide... (the guide is not clear (2nd bullet point in "Before you begin") on which set of credentials to use - It says get the "service credentials" and credentials from the new service created - I tried with both and both fail with the same error below.)
Error:
12-11 01:49:56.201 29584-29632/? I/CredentialUtils: JNDI string lookups is not available. 12-11 01:49:56.269 29584-29632/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default 12-11 01:49:56.723 29584-29632/? D/OkHttp: --> POST https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13 http/1.1 (1297-byte body) 12-11 01:49:56.803 29584-29632/? D/OkHttp: <-- 401 Not Authorized https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13 (78ms, unknown-length body) 12-11 01:49:56.863 29584-29632/? E/WatsonService: POST https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13, status: 401, error: Not Authorized 12-11 01:49:56.865 29584-29632/? E/ERROR: Unauthorized: Access is denied due to invalid credentials
com.ibm.watson.developer_cloud.service.exception.UnauthorizedException: Unauthorized: Access is denied due to invalid credentials at com.ibm.watson.developer_cloud.service.WatsonService.processServiceCall(WatsonService.java:492) at com.ibm.watson.developer_cloud.service.WatsonService$2.execute(WatsonService.java:254) at com.upen.personalityapp.MainActivity$RetrieveFeedTask.doInBackground(MainActivity.java:105) at com.upen.personalityapp.MainActivity$RetrieveFeedTask.doInBackground(MainActivity.java:87) at android.os.AsyncTask$2.call(AsyncTask.java:306) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:244) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) 12-11 01:49:56.866 29584-29584/?
This is the code I am using; I am trying to pass a "text" input to the service.
service = new PersonalityInsights("2017-10-13");
service.setUsernameAndPassword("{myUsername}", "{myPassword}");
Profile profile = service.getProfile(text).execute();
System.out.println(profile);
return profile.toString();
I am using the com.ibm.watson.developer_cloud:personality-insights:3.8.0 dependency.
I tried connecting to the URL in the error (https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13 ) via a browser. It prompts for a username/password combo. I entered my details from my IBM Cloud Lite service but it throws the HTTP Error 405. Is this how it's supposed to work on the browser?
For someone in the future;
Instead of service.setUsernameAndPassword(username, password);, I tried service.setUsernameAndPassword("username", "password"); and it worked.

"unsupported URL" error given when accessing api gateway endpoint from swift

I have the following code that is trying to invoke and api gateway function called endsession in swift:
client.endsessionPost(body: pleasegod!).continue ({ (task:AWSTask) -> Any? in
if let error = task.error {
print("Error occurred: \(error)")
return nil
}
if let result = task.result {
print("IT WORKED")
// Do something with result
}
return nil
})
It runs and completes but task error occurs and the print statement of what the error is says:
Error occurred: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSUnderlyingError=0x618000056e60 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "(null)"}, NSErrorFailingURLStringKey=(null)/endsession, NSErrorFailingURLKey=(null)/endsession, NSLocalizedDescription=unsupported URL}
It seems to be saying the endpoint url provided is bad. The endpoint url was just copied and pasted from the endpoint of the api gateway deployment so I am not sure why that would be an unsupported url.
The endpoint has a format like so:
https://kco37e2fsa.execute-api.us-west-1.amazonaws.com/TheStage
When I visit this endpoint in a browser I notice it says:
{"message":"Missing Authentication Token"}
Which is strange since both my api gateway resources have Authorization set to None and API Key set to not required on all their methods. Is this missing authentication token a clue as to why I am getting unsupported URL errors in swift when invoking the API??
The url https://xxxxxxxxxx.execute-api.us-west-1.amazonaws.com/TheStage will only work if you have a GET method configured on the root resource, and if that is deployed to a stage called TheStage. (No sure if the API Id and/or stage are real). A browser will send a GET request if you just navigate to the URL.
I would recommend a tool like Postman for testing API calls; you can configure parameters, body, HTTP method, auth, etc.

Dropbox API returning http 500 status instead of http 400 status for a non-existant user in a team

Starting at around 21:00 PM GMT today , when we query for a user which doesn't exist in dropbox team, we are receiving an http 500 status with internal error message. In comparison earlier we use to receive http 400 message with message that user doesn't exist in team.
Has something regressed at dropbox end, or is this change intentional and hence we should consider http 500 internal error as equivalent to user not found?
For example RESPONSE#1 is what we expected as valid behavior , while RESPONSE#2 is what we are receiving currently
RESPONSE#1
Resource: https://api.dropbox.com/1/idm/get_profile?email=dummy#authentication.test
Operation: GET
Headers: Authorization: Bearer XXX
Content Type:
Data:
%% Time: 08/28/2014 17:06:51 GMT
Message: The remote server returned an error: (400) Bad Request. Web Response: {"error": "User not on this team"} ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
RESPONSE#2
Resource: https://api.dropbox.com/1/idm/get_profile?email=dummy#authentication.test
Operation: GET
Headers: Authorization: Bearer XXX
Content Type:
Data:
Time: 08/28/2014 22:40:29
(500) Internal Server Error. Web Response: {"error": "Internal Server Error"} ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
Thanks
Somesh