How To Set Authorization Header In Postman
In this activity, you'll event the Postal service
request to generate a security token that you can apply to authorize additional requests. Your Postal service dna/system/api/v
1
/auth/token
request provides a valid username and countersign to DNA Center as a cord that is the base 64 encoding of the username dna/system/api/five
i
/auth/token:
password string. This encoded cord is the value of the Say-so header that accompanies your request.
Note | To improve readability, the remainder of this department uses a shorthand annotation refers to this request more simply as Postal service /token. In practice, this request would actually Mail service to the post-obit URL: Yous tin can ever detect the full request path for any Dna Center Platform API in the DNA Center API Reference documentation. |
Although this guide uses Postman, you can use any HTTP customer or HTTP-enabled code library that yous prefer.
-
Use Postman or another HTTP client to create a POST
https://
fqdnOrIPofDNACenterPlatformdna/system/api/v
1
/auth/token-
In this request path, supplant fqdnOrIPofDNACenterPlatform with the IP address of your DNA Center instance. For example, to use the DevNet Always-On Sandbox, supplant fqdnOrIPofDNACenterPlatform with the
sandboxdnac.cisco.com
domain name. -
For an introduction to creating requests in Postman, see REST Request Basics.
-
-
Add to your request an Potency header that provides the base 64 encoding of username
:
password as its value.-
In the Postman Authorization tab below the URL field, pull down the Blazon menu and select Basic Auth.
Postman displays a login form.
-
Enter your username and password in the appropriate fields and so click Update Asking.
Postman sets the value of the Authorisation header to the word Basic followed by the base 64 encoding of the username
:
password cord.Tip
If you are not using Postman, you can generate the base 64 encoding of username
:
password in a variety of other ways. For instance, in Python 2.7.1 , you can enter'username:password'.encode('base64')
at the Python command prompt. To catechumen the encoded value back to obviously text, enter'encoded_string'.decode('base64')
at the Python control prompt. (If you tin't cosign successfully, try using thedecode
command to make certain that the encoded string provides the correct credentials.)
-
-
Add to your request a Content-Blazon header that has
awarding/json
as its value.-
In Postman, click Headers tab below the URL field.
Postman displays the headers to be sent with this asking. For instance, the Potency header that you created in the previous step should be visible.
-
Enter
Content-Type
in the fundamental field that appears beneath the Authorization header.When yous click the key field, an additional, empty key field appears; every bit you blazon, possible blazon-alee matches appear. When you are satisfied with your entry, printing Enter on your keyboard.
-
In the value field that appears to the right of the
Content-Type
key that you lot simply created, typeapplication/json
and so printing Enter.
The Content-Type header indicates the MIME blazon of the torso of the asking; in this case, the
application/json
value specifies that the trunk is JSON. You lot'll meet that nigh responses from Dna Center return this header value, as well, because these responses provide a JSON-formatted response body. -
-
Send the asking; for example, click the Transport button in Postman.
A successful request returns 200 OK and the response body contains a
Token
aspect that provides the token itself. The token remains valid within the boundaries of session timeout.Important
Treat security tokens as highly confidential data!
-
Before using a token, verify its signature.
-
Shop tokens securely. For more information, see Where to Store Your JWTs.
-
Destroy saved tokens when your application closes or the user logs out. Y'all cannot invalidate a token on demand; information technology remains valid on Deoxyribonucleic acid Heart Platform until it expires. Therefore, it is important for your application to manage tokens securely.
-
-
To authorize subsequent requests, pass the token every bit the value of the Ten-Auth-Token header of the request; later in this guide, y'all'll use this token to send several requests.
What to exercise next
Examine the HTTP response and the security token that Deoxyribonucleic acid Center returned; run across Examining a Successful Asking.
Source: https://pubhub.devnetcloud.com/media/dna-center/docs/documents/b_DNAC_NB_REST_GSG-ciscotopichtml/c_post_token_dnacp_api_gsg.html
0 Response to "How To Set Authorization Header In Postman"
Post a Comment