How to do Http Basic access authentication from advance rest client
Asked Answered
R

3

8

I am trying to do basic authentication to call a rest service.

On service doc the procedure mentioned for CURL is like this

curl -X POST https://secure.clientservice.com/api/transactions.json -u [TOKEN]:[KEY] -H 'Content-type: application/json' \
-d "{\"transaction_type\":\"request\",\"amount_in_cents\":\"3000\",\"email\":\"[email protected]\"}"

I got stuck how to send the [TOKEN]:[KEY] for authentication from chrome rest client.I am having both user token and key and doc is saying i have to do Http Basic access authentication

On rest explorer i am trying like below

enter image description here

But this is giving un authorized access as seems to be the Authorization header is wrong where i am encoding [axkKtfBAaPABCh59SA]:[S7RwBG2eZ3y8mDs8VS] this value to base 64. Am i doing in right way or am i missing something.

Remains answered 17/5, 2016 at 10:20 Comment(0)
C
19

Add the Authorization header: Header Forms --> ADD HEADER --> Begin typing in Authorization.

enter image description here

and add the basic auth info by clicking on the Edit (pencil) button on the right. A form to fill credentials will pop up: enter image description here

Advanced REST Client will take care of encoding

Concentric answered 17/5, 2016 at 11:3 Comment(0)
D
2

I think should encode without the "[" “]“, it could be your problem. Also verify that your token is still valid (it could be expired)

if this doesn't solve your problem can you provide me the error message you get (in your picture the result seems to be ok).

Duckboard answered 17/5, 2016 at 10:45 Comment(2)
thank you , you mean the string to be encoded should be like "axkKtfBAaPA:S7RwBG2eZ3" or axkKtfBAaPA:S7RwBG2eZ3 i tried in these ways too .. i got 401: Unauthorized saying error { "error": "You need to sign in or create an account before continuing." } which is a custom errorRemains
How did you get the token ? it seems that the token is not link to a user so it can't be indentified.Duckboard
D
1

This is an Old question, and has been answered as to how this should be done in Advanced REST Client. But i would still like to point out that you need to enter the basic Authentication Header like this: Header Name: Authorization Header Value: Basic

so if your username was user1 and password was abc then you would need to find the base64 encoded value of "user1:abc" which is "dXNlcjE6YWJj" (you can do this in one of many online tools available, just serach for "base 64 encode online"). In this case your header will become like: Authorization -> Basic dXNlcjE6YWJj

Deb answered 10/7, 2019 at 12:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.