Skip to content

Commit 1d4da98

Browse files
Merge pull request #10 from MastercardDevs/master
add badges and interceptor flag
2 parents 147d676 + 9aea158 commit 1d4da98

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# oauth1-signer-python
22

3-
[![](https://img.shields.io/badge/license-MIT-yellow.svg)](https://github.com/Mastercard/oauth1-signer-java/blob/master/LICENSE)
3+
[![](https://travis-ci.org/MastercardDevs/oauth1-signer-python.svg?branch=master)](https://travis-ci.org/MastercardDevs/oauth1-signer-python)
4+
[![](https://sonarcloud.io/api/project_badges/measure?project=MastercardDevs_oauth1-signer-python&metric=alert_status)](https://sonarcloud.io/dashboard?id=MastercardDevs_oauth1-signer-python)
5+
[![](https://sonarcloud.io/api/project_badges/measure?project=MastercardDevs_oauth1-signer-python&metric=coverage)](https://sonarcloud.io/dashboard?id=MastercardDevs_oauth1-signer-python)
6+
[![](https://sonarcloud.io/api/project_badges/measure?project=MastercardDevs_oauth1-signer-python&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=MastercardDevs_oauth1-signer-python)
7+
[![](https://img.shields.io/pypi/v/mastercard-oauth1-signer.svg?style=flat&color=blue)](https://pypi.org/project/mastercard-oauth1-signer)
8+
[![](https://img.shields.io/badge/license-MIT-yellow.svg)](https://github.com/MastercardDevs/oauth1-signer-python/blob/master/LICENSE)
9+
410

511
## Table of Contents
612
- [Overview](#overview)
@@ -13,6 +19,7 @@
1319
* [Loading the Signing Key](#loading-the-signing-key)
1420
* [Creating the OAuth Authorization for a GET](#creating-the-oauth-get)
1521
* [Creating the OAuth Authorization for a POST](#creating-the-oauth-post)
22+
* [Complete code to use interceptors](#using-interceptors)
1623

1724

1825

@@ -110,3 +117,30 @@ print(r.text)
110117
```
111118

112119

120+
121+
##### Complete snippet to use interceptors : <a name="using-interceptors"></a>
122+
123+
``` python
124+
signing_key = authenticationutils.load_signing_key('your-keyFile.p12', 'the-keystore-password')
125+
consumer_key = 'your-consumer-key-from-developer.mastercard.com'
126+
127+
baseUrl = 'https://sandbox.api.mastercard.com'
128+
129+
service_cli = APIClientYourService()
130+
add_signing_layer(self, service_cli, key_file, key_password, consumer_key)
131+
132+
queryMap = {
133+
"Format": "JSON", # change this to toggle between and XML or JSON response
134+
"fxDate": "2016-09-30",
135+
"transCurr": "ALL",
136+
"crdhldBillCurr": "DZD",
137+
"bankFee": "5",
138+
"transAmt": "23"
139+
}
140+
141+
uri = baseUrl + "/settlement/currencyrate/conversion-rate"
142+
143+
r = test_cli.request('GET', uri, query_params=queryMap)
144+
print(r.text)
145+
146+
```

oauth1/signer_interceptor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def request_function(*args, **kwargs): # pragma: no cover
3838

3939
return func(*args, **kwargs)
4040

41+
request_function.__oauth__ = True
4142
return request_function
4243

4344

tests/test_interceptor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_add_interceptor(self):
5959

6060

6161
""" these will fail because the test keys can't access the service, you'll need to insert a valid key file, password, and consumer key """
62-
def test_without_interceptor(self):
62+
def localonly_test_without_interceptor(self):
6363
if os.path.exists('./test_key_container.p12'):
6464
key_file = './test_key_container.p12'
6565
key_password = "Password1"
@@ -85,7 +85,7 @@ def test_without_interceptor(self):
8585
print(r.text)
8686

8787
""" these will fail because the test keys can't access the service, you'll need to insert a valid key file, password, and consumer key """
88-
def test_with_interceptor(self):
88+
def localonly_test_with_interceptor(self):
8989
if os.path.exists('./test_key_container.p12'):
9090
key_file = './test_key_container.p12'
9191
key_password = "Password1"

0 commit comments

Comments
 (0)