Skip to content

Commit 06ddbd9

Browse files
committed
fix: Update Network APIs code snippets
1 parent 2e5fd82 commit 06ddbd9

File tree

8 files changed

+55
-53
lines changed

8 files changed

+55
-53
lines changed

config.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,27 @@ ACCOUNT_SMS_CALLBACK_URL=${ACCOUNT_SMS_CALLBACK_URL:-"https://example.com/inboun
2424

2525
# Messages
2626

27+
# Network APIs
28+
VNA_PHONE_NUMBER=${VNA_PHONE_NUMBER:-""}
29+
VNA_SCOPE=${VNA_SCOPE:-""}
30+
VNA_STATE=${VNA_STATE:-""}
31+
VNA_AUTH_REQ_ID=${VNA_AUTH_REQ_ID:-""}
32+
VNA_ACCESS_TOKEN=${VNA_ACCESS_TOKEN:-""}
33+
2734
# Number Insight
2835
INSIGHT_NUMBER=${INSIGHT_NUMBER:-""}
2936
INSIGHT_CALLBACK_URL=${INSIGHT_CALLBACK_URL:-""}
3037

3138
# Number Verification
39+
NV_AUTH_CODE=${NV_AUTH_CODE:-""}
40+
NV_REDIRECT_URI=${NV_REDIRECT_URI:-""}
3241

3342
# Numbers
3443

3544
# Reports
3645

3746
# Sim Swap
47+
SIMSWAP_MAX_AGE=${SIMSWAP_MAX_AGE:-""}
3848

3949
# SMS
4050

@@ -178,13 +188,6 @@ VBC_PASSWORD=${VBC_PASSWORD:-""}
178188
ROOM_DISPLAY_NAME={ROOM_DISPLAY_NAME:-""}
179189
EXPIRATION_DATE={EXPIRATION_DATE:-""}
180190

181-
# Network APIs
182-
PHONE_NUMBER=${PHONE_NUMBER:-""}
183-
MAX_AGE=${MAX_AGE:-""}
184-
AUTH_REQ_ID=${AUTH_REQ_ID:-""}
185-
AUTH_CODE=${AUTH_CODE:-""}
186-
REDIRECT_URI=${REDIRECT_URI:-""}
187-
188191
# Application API
189192
USER_ID=${USER_ID:-""}
190193
USER_NAME=${USER_NAME:-""}

network-apis/camara-auth/backend.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
source "../../config.sh"
44
source "../../jwt.sh"
5-
source "oidc.sh"
65

7-
curl -X POST https://api-eu.vonage.com/oauth2/token \
8-
-H 'Authorization: Bearer '$JWT\
9-
-H 'Content-Type: application/x-www-form-urlencoded' \
10-
-d 'auth_req_id='"$AUTH_REQ_ID"'' \
11-
-d 'grant_type=urn:openid:params:grant-type:ciba'
6+
curl https://api-eu.vonage.com/oauth2/token \
7+
--header "Authorization: Bearer $JWT" \
8+
--header "Content-Type: application/x-www-form-urlencoded" \
9+
--data-urlencode "auth_req_id=$VNA_AUTH_REQ_ID" \
10+
--data-urlencode "grant_type=urn:openid:params:grant-type:ciba"

network-apis/camara-auth/frontend.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
source "../../config.sh"
44
source "../../jwt.sh"
55

6-
curl -X POST https://api-eu.vonage.com/oauth2/token \
7-
-H 'Authorization: Bearer '$JWT\
8-
-H 'Content-Type: application/x-www-form-urlencoded' \
9-
-d 'code='$AUTH_CODE \
10-
-d 'redirect_uri='$REDIRECT_URI \
11-
-d 'grant_type: authorization_code'
6+
curl https://api-eu.vonage.com/oauth2/token \
7+
--header "Authorization: Bearer $JWT" \
8+
--header "Content-Type: application/x-www-form-urlencoded" \
9+
--data-urlencode "code=$AUTH_CODE" \
10+
--data-urlencode "redirect_uri=$REDIRECT_URI" \
11+
--data-urlencode "grant_type: authorization_code"

network-apis/camara-auth/oidc.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env bash
22

3+
source "../../config.sh"
34
source "../../jwt.sh"
45

56
curl -X POST https://api-eu.vonage.com/oauth2/bc-authorize \
6-
-H 'Authorization: Bearer '$JWT\
7-
-H 'Content-Type: application/x-www-form-urlencoded' \
8-
-d 'login_hint='"$PHONE_NUMBER"'' \
9-
-d 'scope='$SCOPE
7+
--header "Authorization: Bearer $JWT" \
8+
--header "Content-Type: application/x-www-form-urlencoded" \
9+
--data-urlencode "login_hint=$VNA_PHONE_NUMBER" \
10+
--data-urlencode "scope=$VNA_SCOPE"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
source "../../config.sh"
4+
source "../../jwt.sh"
5+
6+
curl -X POST https://api-eu.vonage.com/v0.1/network-enablement \
7+
--header "Authorization: Bearer $JWT" \
8+
--header "Content-Type: application/json" \
9+
--data $'{
10+
"phone_number": "'$VNA_PHONE_NUMBER'",
11+
"scopes": ["'$VNA_SCOPE'"],
12+
"state" : "'$VNA_STATE'"
13+
}'
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#!/usr/bin/env bash
22

33
source "../../config.sh"
4-
source "../camara-auth/frontend.sh"
5-
64

75
curl -X POST https://api-eu.vonage.com/camara/number-verification/v031/verify \
8-
-H 'Authorization: Bearer '$ACCESS_TOKEN\
9-
-H 'Content-Type: application/json' \
10-
-H 'Accept: application/json' \
11-
-d $'{
12-
"phoneNumber": "'$PHONE_NUMBER'",
13-
"maxAge": "'$MAX_AGE'"
6+
--header "Authorization: Bearer $VNA_ACCESS_TOKEN" \
7+
--header "Content-Type: application/json" \
8+
--data $'{
9+
"phoneNumber": "'$VNA_PHONE_NUMBER'"
1410
}'

network-apis/sim-swap/check-sim-swap.sh

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22

33
source "../../config.sh"
44

5-
SCOPE='openid dpv:FraudPreventionAndDetection#check-sim-swap'
6-
source "../camara-auth/backend.sh"
7-
8-
95
curl -X POST https://api-eu.vonage.com/camara/sim-swap/v040/check \
10-
-H 'Authorization: Bearer '$ACCESS_TOKEN\
11-
-H 'Content-Type: application/json' \
12-
-H 'Accept: application/json' \
13-
-d $'{
14-
"phoneNumber": "'$PHONE_NUMBER'",
15-
"maxAge": "'$MAX_AGE'"
16-
}'
6+
--header "Authorization: Bearer $VNA_ACCESS_TOKEN" \
7+
--header "Content-Type: application/json" \
8+
--data $'{
9+
"phoneNumber": "'$VNA_PHONE_NUMBER'",
10+
"maxAge": '$SIMSWAP_MAX_AGE'
11+
}'

network-apis/sim-swap/retrieve-sim-swap-date.sh

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22

33
source "../../config.sh"
44

5-
SCOPE='openid dpv:FraudPreventionAndDetection#retrieve-sim-swap'
6-
source "../camara-auth/backend.sh"
7-
8-
9-
curl -X POST https://api-eu.vonage.com/camara/sim-swap/v040/retrieve \
10-
-H 'Authorization: Bearer '$ACCESS_TOKEN\
11-
-H 'Content-Type: application/json' \
12-
-H 'Accept: application/json' \
13-
-d $'{
14-
"phoneNumber": "'$PHONE_NUMBER'",
15-
}'
5+
curl -X POST https://api-eu.vonage.com/camara/sim-swap/v040/retrieve-date \
6+
--header "Authorization: Bearer $VNA_ACCESS_TOKEN" \
7+
--header "Content-Type: application/json" \
8+
--data $'{
9+
"phoneNumber": "'$VNA_PHONE_NUMBER'"
10+
}'

0 commit comments

Comments
 (0)