How to get a list of users who logged in after a certain date via YouTrack API? - youtrack

I need to get a list of users who logged in within the last 2 years. YouTrack Web interface shows me 141 users on /admin/hub/users?query=lastAccess(after:%202018-01-01)
But when I try to get the same list via API, I get an empty array. What am I doing wrong?
Here's my API request:
curl -X GET "https://[my_youtrack_URL]/api/admin/users?query=lastAccess(after:%202018-01-01)&$skip=0&$top=200"

What am I doing wrong?
You're missing an authentication token.
Try adding the following to your curl command -H "Authorization: Bearer mytoken123". The token itself can be created in your YouTrack user profile.

I got the answer from the YouTrack developers, it's two-fold:
1) First, the endpoint for request concerning users is different - this is a "hub" feature, so the endpoint should be /hub/api/rest/users (as also mentioned by #Jk1 above).
2) Second, the correct syntax for the query is lastAccess(after:+2018-01-01) (+ instead of %20).

Related

LinkedIn API App - "Resource search does not exist"/"Empty oauth2 access token"

I am working on a simple searching app using LinkedIn's API.
I have set my base-url for the LinkedIn Sales Navigator to:
base_url = "https://api.linkedin.com/v2/search"
I have also obviously added my client_id, client_secret, and access_token in the headers.
However, upon running the program, I am getting the error:
{"serviceErrorCode":0,"message":"Resource search does not exist","status":404}
This makes me think that there is a problem with the base-url. But then, upon visiting the link my program is trying to visit, I am met with a JSON that says:
serviceErrorCode 65604 message "Empty oauth2 access token" status 401
However, as far as I am concerned, I have gone through the OAuth2 flow correctly and in full.
But I'm not sure what it actually is.
Any ideas?
Thanks in advance.
this search point is depreciated. this is allowed to the selected developer only. First, make sure that you have the permissions for that. For reference, you can visit this link
The other thing, if you have permission, then you need to pass the bearer token in the header for authorization.
curl --location --request GET 'https://api.linkedin.com/v2/search' \
--header 'Authorization: Bearer {INSERT_TOKEN}' \
The complete information can be found here.

Trying to login using oauth. Can someone explain the documentation how to get access token?

I understand that I need to call:
curl --request POST \
--url 'https://auth.atlassian.com/oauth/token' \
--header 'Content-Type: application/json' \
--data '{"grant_type": "authorization_code","client_id": "YOUR_CLIENT_ID","client_secret": "YOUR_CLIENT_SECRET","code": "YOUR_AUTHORIZATION_CODE","redirect_uri": "https://YOUR_APP_CALLBACK_URL"}'
to get access token. There is some attempt to explain what are client_id, client_secret, code, redirect_uri, but it's totally cryptic to me. Can someone explain to me, what these are and where to get them?
I can login to company jira. I can create my personal access token in my profile. I cant get any meaningful support from my company. I need to get somehow from here to access token, so that I can call rest api.
OAuth needs that the user login through a web interface.
Once logged, is possible to retrieve the code you are looking for in the URL.
In my case, in order to get that code I have to open the oauth login web page of the service I want to use (in your case atlassian) and just login.
I usually manage this process with code, not using curls.
redirect_uri is where you want to be redirected after you login in the web interface.
i.e. Do I need to login with atlassian in order to call api and use data from my app ?
mobile app/Desktop App (redirect_uri will be a schema defined by you in the app, could be something like: myCompany://myApplicationExample or with desktop http://localhost should work ). In this case I suggest you to read something about deeplink for applications.
website (redirect_uri will the url of your website : https://yourwebsite.com
In my case, with the services I usually work with, cliend_id and client_secret are given per user or per application, when requested to the company which provides services you need.
I hope this can help you clarify
BY THE WAY:
if you say you already have an Access Token , you should be able to do everything without Loggin in, because the final purpose of login and use all this parameters you asked for, is to get an Access Token.
The endpoint you are trying to call, will just return you an Access Token.
The Access token is what you need in order to call rest api in this case.
I would suggest you to try to call an atlassian rest API you want, using the Access Token you already have in the headers of the rest API, and see the results.
In my case, I have to create an header like this:
Authorization : Bearer {your Access token}
I hope this helps you.
EDIT:
As shown in point 1 in this doc https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/
you should open this url by your application:
https://auth.atlassian.com/authorize?
audience=api.atlassian.com&
client_id=YOUR_CLIENT_ID&
scope=REQUESTED_SCOPE_ONE%20REQUESTED_SCOPE_TWO&
redirect_uri=https://YOUR_APP_CALLBACK_URL&
state=YOUR_USER_BOUND_VALUE&
response_type=code&
prompt=consent
read the doc on you should set redirect_uri (http://localhost is valid if is a desktop application, but you will have to implement an http listener in order to get the authorization code, I suggest you to set a schema in you app or simply use a web page url).
You should get a client_id by atlassian to use in the url,same for scope.
I don't know exaclty the state parameter but in the docs should be writtend.
Once logged you will be redirected to the redirect_uri you set, getting also this authorization_code, then you can call the /token endpoint in order to get the Access Token.
curl --request POST \
--url 'https://auth.atlassian.com/oauth/token'
--header 'Content-Type: application/json'
--data '{"grant_type": "authorization_code","client_id": "YOUR_CLIENT_ID","client_secret": "YOUR_CLIENT_SECRET","code": "YOUR_AUTHORIZATION_CODE","redirect_uri": "https://YOUR_APP_CALLBACK_URL"}'
Here you have to use the authorization code you get from the login, re use the same client_id, set also the client_secret (should be given with the client_id) and re use the same redirect_uri you used in the login url.
Once done you will have finally the Access Token, which must be used in order to call Apis.
as shown in the doc you should be able to call apis like this curl
curl --request GET \
--url https://api.atlassian.com/oauth/token/accessible-resources
--header 'Authorization: Bearer ACCESS_TOKEN'
--header 'Accept: application/json'
Where 'ACCESS_TOKEN' will be your access token obtained before.
Remind that an Access Token usually has an expiration date, after which you will need to login again or refreshing the token.
EDIT 2:
A Client ID is an identifier associated with an application that assists with client / server OAuth 2.0 authentication.
So basically is a constant string, this should be given to you from atlassian/jira in some way.
Client Secret should be given to you with Client ID from atlassian/jira.
Client_id and client_secret usually are also called api keys.
Usually the Scope is the name of the application you are requesting api keys for (you should request new api keys for each application),this is up to you, and should be comunicated to the company in your case (atlassian/jira) when requesting api keys.
(i.e. For my company I work with Trimble Connect, which is just a platform, everytime I develop for example a plugin/addon on top of it I ask them new api keys)
for what concerns the state:
state: (required for security) Set this to a value that is associated with the user you are directing to the authorization URL, for example, a hash of the user's session ID. Make sure that this is a value that cannot be guessed. You may be able to generate and validate this value automatically, if you are using an OAuth 2.0 client library or an authentication library with OAuth 2.0 support.
In the beginning I would try to give the state a random value.
I think you should ask to Atlassian how to get your api keys (maybe there's a page for that, like for Trimble Connect in my case).
I would send them an e-mail.
Seems you are not interested in call Apis from an application you are developing, but just from curls.
if I'm right, I know I have already told you, but if I were you I would definitely try to call an atlassian API not trying to get the access token from the OAuth Login, but using that ACCESS TOKEN you told me you told me you manually created.
Please try this curl:
curl --request GET \
--url https://api.atlassian.com/oauth/token/accessible-resources
--header 'Authorization: Bearer {ACCESS_TOKEN}'
--header 'Accept: application/json'
just use your Access Token string instead of {ACCESS_TOKEN} and see the results.

How to get fullAccountNumber in Yodlee

Calling the /accounts/{accountId} endpoint with the include fullAccountNumber returns an error Y821 - fullAccountNumber not supported.
I'm doing:
curl -i -H "Api-version: 1.1" -H "Authorization: Bearer {token}" -X
GET https://production.api.yodlee.com/ysl/accounts/{accountId}
?container=bank&include=fullAccountNumber,holder,profile
Note: the line breaks are just for readability
How do you get fullAccountNumber?
It looks like you are calling the API correctly. This feature needs to be enabled for your account, after approval from the Yodlee Security Office. You can make an application through your account manager.
The error message should be updated to something more helpful, like “fullAccountNumber feature is not enabled for account. Please contact Yodlee support.”
Circling back to this because it's been more than a year and want to have a solution:
This was not possible with Yodlee and we went with a different solution.

Why am I getting 401 UnauthorizedError when getting a list of events using the SocialTables API?

I am trying to use the API Console to get access to event information. When I use https://api.socialtables.com/4.0/events/ I get a 401 response code, where I expect to see a list of events that I have created.
I am the owner on the account, and other calls in the API Console are working. I can query https://api.socialtables.com/4.0/users/ with my user id and https://api.socialtables.com/4.0/accounts/ with my account id.
I get the same behavior when calling the API from Postman.
Update
I was able to find my team id by inspecting the URL. It appeared to be an legacy numeric id, so I tried one of the legacy endpoints:
https://api.socialtables.com/4.0/legacyvm3/teams/[TEAM-ID]/events
That works, and returns the list of events that I expected. However, it only returns the legacy id values. I'd prefer to strictly use the newer ids and API endpoints.
Thanks for using our API. I couldn't reproduce the 401 unauthorized issue, but I noticed our trial signup put you in the 3.0 version, which is why you see your 3.0 events. Our trial process is currently being revised to put people in our latest version, and will do that soon.
In the meantime I went ahead and migrated your account to 4.0 and created a test v4 event.
Using this curl gives me the expected result:
curl --request GET \
> --url https://api.socialtables.com/4.0/events \
> --header 'authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXade8'
If you have further questions I'd be happy to assist.

How to make Twitter API call through curl in unix

I would like to pull the data from Twitter REST API. I have created the consumer key, secret and Access token, secret. I have tried with "Test OAuth", it generates a CURL command but if I change any one parameter then it is giving the below error.
Message: {"errors":[{"code":32,"message":"Could not authenticate you."}]}
Now I would like to call the twitter API using CURL in shell script for different screenNames.
I want a sample command some thing like mentioned below
curl --get 'https://api.twitter.com/1.1/statuses/user_timeline.json' --data 'count=2&screen_name=aswin' APIKEY:"xxxxxx",Acesstoken:"yyyyyyyy"
Thanks in advance.
Regards,
Aswin
I found the answer.
curl --get 'https://api.twitter.com/1.1/statuses/user_timeline.json' \
--data 'count=2&screen_name=twitterapi' \
--header 'Authorization: OAuth oauth_consumer_key="AAAAAAAAAAAAAAAAAAAA", oauth_nonce="BBBBBBBBBBBBBBBBBBBBBBB", oauth_signature="CCCCCCCCCCCCCCCCCCCCCCCCCCC", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1471672391", oauth_token="DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", oauth_version="1.0"'
Since your specific query doesn't require a user context you can use Application only authentication to make this request. The bearer token won't change per request so it should allow you to keep using curl.
https://dev.twitter.com/oauth/application-only
n.b. it won't work for all endpoints, but should for the case you listed.
Because most twitter requests require calculating the oauth signature, you should either write a client yourself or reuse an existing command line client.
https://github.com/twitter/twurl
https://github.com/sferik/t
https://github.com/yschimke/oksocial/wiki (Mac focused/cross service)
As you saw any change to the request will generally invalidate the query, and even time is one of the inputs.