Api Get Method using rest api how to send authendication Error

I am Creating Tyk api with authontication. but i call url its show authontication Failed how to send username And passwrod using Url

Hi, what kind of authentication are you using?

How do you send this request?

Hi Matias, Thanks for your prompt response.

Developer is not available now.

Can you please provide some good example, so that we can try.

Thanks

It will be useful to know the authentication mechanism you’re using, so I can point you to a specific example.

The general approach for authentication mechanisms is to use HTTP headers, however it’s also possible to use query parameters or cookies in some cases.

Check the Access Control List documentation, you can see a sample GET request, that uses a HTTP header for authentication:

https://tyk.io/docs/tyk-api-gateway-v-2-0/access-control/standard-access-tokens/

actually what is default port in tyk. and “-api-auth: 53ac07777cbb8c2d53000002d698728ce964432d7167596bc005c5fc” Where it can be located on this key

If you’ve installed Tyk using one of these guides) and you have executed the commands like the examples, Tyk will be listening on port 8080.

Tyk exposes a REST API for managing all the settings, you may find the methods for retrieving and creating keys here:

https://tyk.io/docs/tyk-api-gateway-v-2-0/tyk-gateway-rest-api/

I suggest this tutorial, it covers the creation of a basic API and key (check step 5):

https://tyk.io/docs/tyk-api-gateway-v-2-0/tutorials/set-up-your-first-api/

1 Like

we are using pro Edition

Acctually i do the process.

This is localhost Api Url : “http://localhost:9000/api/things”. i want to change the External api So i Do This steps.

Note: First Thing is It possible to access to local to server. (My Code is Not Any Server or Domain. only i store in My Local system) ?.

In case is it Possible I do This steps But Its show Empty Page.

  1. I GO this Link “Tyk.io Login
  2. System Mgmt → apis → “ADD New Api” Click.
  3. Given Api Name: “xxx” and Target URL: “http:localhost:9000/api/things”.
  4. after i save and click Import. Then its generate some api url. After i copy That Api url And Past In New Tab. But its comming Empty Page.

@rajivgandhi.vivid It sounds like you are using Tyk Cloud - if that is the case, then you won’t be able to proxy localhost as your URL will need to be publicly resolvable.

There is an exception to this rule if you are using Tyk Cloud with our hybrid mode. as @matiasb said, can you let us know how you installed Tyk?

no. we just testing on pro Edition. through online

Tyk install in Ubuntu in my local system it’s show Error.

I GIve this command : “sudo apt-get install -y mongodb-org redis-server tyk-gateway tyk-dashboard”

Error :

Need to get 17.1 MB of archives.
After this operation, 56.9 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
tyk-dashboard tyk-gateway
E: There are problems and -y was used without --force-yes

Hi, this problem could be related to APT and the GPG keys, can you try these commands?

For Tyk:

curl https://packagecloud.io/gpg.key | sudo apt-key add -

For Mongo:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

Finally:

apt-get update
apt-key update

Please retry the apt-get install command right after this.

ok. i do it after what i do. is it any code written in my local file ?

after the steps run tyk “> sudo service tyk-gateway start”. after what i do

i need to localhost url run in External using tyk

my localhost url “http://localhost:9000/api/bikes” this url run to external using tyk what the process.

I try to generate new api > “https://vividinfotech.cloud.tyk.io/local/” using above localhost api. But Its show Empty Page.

and It’s Show Error in console

Error:

Failed to load resource: the server responded with a status of 504 (GATEWAY_TIMEOUT)

OK, I create Api And Generate Keys

key : 57740e4905147b0001000041a7ade734459744504b4148ae4122a727

Dashboard API Key : 29c14c067c094b8f4782c2fe1e1a3e12

AppID : e9f3311cb442477761c7aceff038486f

After I Go to in my Terminal and Give this

$ curl -H “Authorization: {57740e4905147b0001000041a7ade734459744504b4148ae4122a727}”
And Give Enter
-s
-H “Content-Type: application/json”
-X POST
-d ‘{
“allowance”: 1000,
“rate”: 1000,
“per”: 1,
“expires”: -1,
“quota_max”: -1,
“quota_renews”: 1449051461,
“quota_remaining”: -1,
“quota_renewal_rate”: 60,
“access_rights”: {
“YOUR-API-ID”: {
“api_id”: “e9f3311cb442477761c7aceff038486f”,
“api_name”: “sample-demo”,
“versions”: [“Default”]
}
},
“meta_data”: {}
}’
http://{https://vividinfotech.cloud.tyk.io/sample-demo/}:8080/api/29c14c067c094b8f4782c2fe1e1a3e12 | python -mjson.tool

After I get This Error What The Reason And How To Solve.

http://{https://vividinfotech.cloud.tyk.io/sample-demo/}:8080/api/29c14c067c094b8f4782c2fe1e1a3e12 | python -mjson.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0curl: (6) Could not resolve host: https
No JSON object could be decoded

Is your endpoint publicly accesible?

No. But I give the command it’s showing.
No JSON object could be decodeded

What The Reason

This One Correct Are Wrong

curl -H “Authorization: {57740e4905147b0001000041a7ade734459744504b4148ae4122a727}”
And Give Enter
-s
-H “Content-Type: application/json”
-X POST
-d ‘{
“allowance”: 1000,
“rate”: 1000,
“per”: 1,
“expires”: -1,
“quota_max”: -1,
“quota_renews”: 1449051461,
“quota_remaining”: -1,
“quota_renewal_rate”: 60,
“access_rights”: {
“YOUR-API-ID”: {
“api_id”: “e9f3311cb442477761c7aceff038486f”,
“api_name”: “sample-demo”,
“versions”: [“Default”]
}
},
“meta_data”: {}
}’
http://{https://vividinfotech.cloud.tyk.io/sample-demo/}:8080/api/29c14c067c094b8f4782c2fe1e1a3e12 | python -mjson.tool

Can you run the curl comand without the Python pipe and using the verbose mode and corresponding authorization headers?

curl --verbose -H "Authorization: abc" http://your_api_endpoint

And then the same command, but targeting your endpoint directly. You probably don’t need authorization headers for this:

curl --verbose http://your_endpoint

This could give me a clearer perspective.

Thanks, i give This

curl --verbose -H “Authorization: abc” http://your_api_endpoint

Comming On Json Out Put. After i go Apis → Edit ->Base Configuration → Enable round-robin load balancing “check Field” → Add LB targets.
After Comming This Url

Upstream targets:
http://jsonplaceholder.typicode.com/users

i try To this Url Its Get Out in Json. Format. Thanks. That it Are Any Other Work Doing Here.

Yesterday I Register New User In TYK.IO . After Login
In Menu Bar Under “SYstem Managment”. Show Lot Of Sub Menu’s.

But To Day I Login Its Show only Api’s.

I Click Apis - >Edit Its Show Error.

!Error
Not authorised

it’s Display in Alert Box. What The Reason.