grzesiek avatar

Bash script - challenge [part 3]. Authentication test (token) using the curl program.

grzesiekb

Published: 19 Mar 2020 › Updated: 19 Mar 2020Bash script - challenge [part 3]. Authentication test (token) using the curl program.

Bash script - challenge [part 3]. Authentication test (token) using the curl program.

Medium level.

Requires:

  1. An account on auth0.
  2. The curl program to be installed.
  3. Basic knowledge of Linux commands.

We need API to test (e.g. https://auth0.com).

Let’s go to API on auth0. (APIs->Settings->Test). Create & AUTHORIZE TEST APPLICATION

image1.png

Create & AUTHORIZE TEST APPLICATION

image3.png

Get access_token

curl --request POST \
  --url https://dev-o1btb-69.eu.auth0.com/oauth/token \
  --header 'content-type: application/json' \
  --data '{"client_id":"tPOxbJ8QEMj8VVZEHPHt7uTM0uAHPd4v","client_secret":"xppOcAF8mqzRvZo9EBfPjIVZzdlfHPiVDyXwsOv1NL-Wx-4IKSMh3wwZllxtgZPF","audience":"https://dev-o1btb-69.eu.auth0.com/api/v2/","grant_type":"client_credentials"}'

And next try to authenticate in test using the curl program.

curl --request GET \
  --url https://dev-o1btb-69.eu.auth0.com/api/v2/ \
  --header 'authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5VSXdOalV4UWtJMVJFUkJOREJHUlVZME5qUXhRak0yTWprMFF6Y3lNVGt5TmpWQ1JFUXhNUSJ9.eyJpc3MiOiJodHRwczovL2Rldi1vMWJ0Yi02OS5ldS5hdXRoMC5jb20vIiwic3ViIjoidFBPeGJKOFFFTWo4VlZaRUhQSHQ3dVRNMHVBSFBkNHZAY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vZGV2LW8xYnRiLTY5LmV1LmF1dGgwLmNvbS9hcGkvdjIvIiwiaWF0IjoxNTgzNTA5NTE3LCJleHAiOjE1ODM1OTU5MTcsImF6cCI6InRQT3hiSjhRRU1qOFZWWkVIUEh0N3VUTTB1QUhQZDR2IiwiZ3R5IjoiY2xpZW50LWNyZWRlbnRpYWxzIn0.eRWje68f11VgEO3mdZ3O-ICIVWlJNAhWx3JOF5-qzNILG9ZGWJ7zMQjUHAKQA0GkxRhWNcwFXpVeNuDwDUcb0IMFmaLfXCpvufcH0Pp_OtGw06iivlZwIjEEmstDUw8CU1gXiIImOOfI8FydrGft33ktkRKr0AN9pxcGUP-LanoaVRC2Lxoa5aNHAiThYk-kAT78-emUBdGG4cE_vGp7psH7BoDgLB7BxKkUgfQV1zAw-rLmXAYq-0h8oqrLZgkEQRCkOpHXa07Ls1W2N754EQbD8z6QuyHcbeicUQmVah_oNkc45v7Qv2r3sqX0BxSIy58OC5ocDWXJ24qd0yZ7eQ

The next topic will be Reporting test results written using bash script.

Table of contents:

[Start] - Writing API tests using the curl program
[part 2] - Authentication test (session) using the curl program.

Leave Bash script - challenge [part 3]. Authentication test (token) using the curl program. to:

Written by

@grzesiekb | scada - programming (open source) - tutorials

Read more #bash posts


Best Posts From grzesiek

We have not curated any of grzesiekb's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From grzesiek