-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bubianchi-criteo
committed
Jun 1, 2023
1 parent
88a3ea3
commit 5dc5619
Showing
159 changed files
with
1,481 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 24 additions & 2 deletions
26
sdks/marketingsolutions_2022-07/criteo_api_marketingsolutions_v2022_07/api_client_builder.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
from criteo_api_marketingsolutions_v2022_07.configuration import Configuration | ||
from criteo_api_marketingsolutions_v2022_07.criteo_api_client import CriteoApiClient | ||
from criteo_api_marketingsolutions_v2022_07 import flow_constants | ||
|
||
class ApiClientBuilder : | ||
|
||
@staticmethod | ||
def WithClientCredentials(clientId, clientSecret): | ||
configuration = Configuration(username=clientId, password=clientSecret) | ||
def WithClientCredentials(clientId, clientSecret, host=None): | ||
configuration = Configuration(username=clientId, password=clientSecret, host=host) | ||
|
||
return CriteoApiClient(configuration) | ||
|
||
@staticmethod | ||
def WithNoAuthorization(): | ||
|
||
return CriteoApiClient() | ||
|
||
@staticmethod | ||
def WithAuthorizationCode(clientId, clientSecret, authorization_code, redirect_uri, host=None): | ||
configuration = Configuration(username=clientId, password=clientSecret, host=host) | ||
additional_parameters = { | ||
'flow' : flow_constants.AUTHORIZATION_CODE_FLOW, | ||
'authorization_code': authorization_code, | ||
'redirect_uri': redirect_uri | ||
} | ||
|
||
return CriteoApiClient(configuration = configuration, additional_parameters = additional_parameters) | ||
|
||
@staticmethod | ||
def WithRefreshToken(clientId, clientSecret, refreshToken, host=None): | ||
configuration = Configuration(username=clientId, password=clientSecret, host=host) | ||
additional_parameters = { | ||
'flow' : flow_constants.REFRESH_TOKEN_FLOW, | ||
'refresh_token': refreshToken | ||
} | ||
|
||
return CriteoApiClient(configuration = configuration, additional_parameters = additional_parameters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
sdks/marketingsolutions_2022-07/criteo_api_marketingsolutions_v2022_07/flow_constants.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""This file defines authentication flows constants.""" | ||
|
||
CLIENT_CREDENTIALS_FLOW = 'client_credentials' | ||
AUTHORIZATION_CODE_FLOW = 'authorization_code' | ||
REFRESH_TOKEN_FLOW = 'refresh_token' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
sdks/marketingsolutions_2022-07/test/example_application_with_auth_code.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from criteo_api_marketingsolutions_v2022_07.api.gateway_api import GatewayApi | ||
from criteo_api_marketingsolutions_v2022_07 import ApiClientBuilder | ||
|
||
class ExampleApplication: | ||
|
||
def call_then_application_endpoint(self, clientId, clientSecret, authorization_code, redirect_uri): | ||
# Create a client using your choosen OAuth flow, Authorization Code in this case. The client will handle the token generation/renewal for you | ||
client = ApiClientBuilder.WithAuthorizationCode(clientId, clientSecret, authorization_code, redirect_uri) | ||
|
||
# The Gateway API regroups common technical endpoints that exists for all versions | ||
# You can find the other endpoints in the other *Api | ||
# You can reuse the same client with several Apis, but be careful, as they will then use the same token and credentials | ||
api = GatewayApi(client) | ||
|
||
# Perform the call to the application introspection endpoint | ||
response = api.get_current_application() | ||
|
||
# Most of Criteo's API response follow the same structure: | ||
# The response consists of a Data, Errors and Warnings fields | ||
# The Data fields contains an Id (if applicable), a Type, and an Attributes field that contains the business object | ||
myApplication = response.data.attributes | ||
print(f'Hello, I\'m using Criteo API and I\'m connected as {myApplication.name}') | ||
|
||
# You will need to save the refresh_token to use it in the refresh_token flow | ||
# You can fetch the refresh token like this: | ||
refreshToken = client.get_refresh_token() | ||
print('The refresh token to be saved is ', refreshToken) |
5 changes: 1 addition & 4 deletions
5
...tions_2022-07/test/example_application.py → ...le_application_with_client_credentials.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.