FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
api-examples/ShellScripts/bash_script.sh at master · tah/api-examples · GitHub
tah
/
api-examples
Public
forked from
jakmanne/api-examples
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
api-examples
/
ShellScripts
/
bash_script.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (24 loc) · 1.08 KB
Breadcrumbs
api-examples
/
ShellScripts
/
bash_script.sh
Copy path
File metadata and controls
31 lines (24 loc) · 1.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!
/bin/bash
#
this script requires `jq` to be installed in order to read json objects.
#
apt-get install jq
#
- or -
#
dnf install jq
#
setup
clientId=
'
*******************
'
secret=
'
******************************
'
userId=
'
***********
'
#
headers
acceptHeader=
'
Accept: application/json
'
contentTypeHeader=
'
Content-Type: application/x-www-form-urlencoded; charset=utf-8
'
#
request body
requestBody=
'
grant_type=client_credentials
'
token=
$(
curl -q -u
"
$clientId
:
$secret
"
-H
"
$acceptHeader
"
-H
"
$contentTypeHeader
"
-d
"
$requestBody
"
'
https://auth.sbanken.no/IdentityServer/connect/token
'
2>
/dev/null
|
jq -r .access_token
)
accounts=
$(
curl -q -H
"
customerId:
$userId
"
-H
"
Authorization: Bearer
$token
"
"
https://api.sbanken.no/Bank/api/v1/Accounts
"
2>
/dev/null
)
matches=
$(
echo
$accounts
|
jq -r .availableItems
)
for
i
in
$(
seq 0
$((
$matches
-
1
))
)
do
accountNumber=
$(
echo
$accounts
|
jq -r
"
.items[
$i
].accountNumber
"
)
balance=
$(
echo
$accounts
|
jq -r
"
.items[
$i
].balance
"
)
name=
$(
echo
$accounts
|
jq -r
"
.items[
$i
].name
"
)
printf
"
%-20s\t%-11s\t%8.2f\n
"
"
$name
"
"
$accountNumber
"
$balance
done
Back
|
FazBrowse Home
|
New Git URL