Skip to content

Commit

Permalink
Add OAuth2 Support to AudienceProcessingRegistration
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillermo Tamanaha authored and GitHub Enterprise committed Sep 14, 2021
1 parent 8274d06 commit e51d67f
Show file tree
Hide file tree
Showing 47 changed files with 718 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mparticle.sdk.model.eventprocessing.*;
import com.mparticle.sdk.model.eventprocessing.notification.SystemNotification;
import com.mparticle.sdk.model.registration.*;
import com.mparticle.sdk.model.registration.authentication.OAuth2Authentication;
import com.mparticle.sdk.model.registration.authentication.ScopeDetail;

import java.util.*;

Expand Down Expand Up @@ -43,8 +45,27 @@ public static Map.Entry<String, ModuleRegistrationResponse> GenerateMessage() {

// Set up Audience Registration.
AudienceProcessingRegistration audienceRegistration = new AudienceProcessingRegistration();
OAuth2Authentication authentication = new OAuth2Authentication();

authentication
.setAuthorizationUrl("TEST_AUTHORIZATION_URL")
.setRefreshUrl("TEST_REFRESH_URL")
.setTokenUrl("TEST_TOKEN_URL")
.setGrantType(OAuth2Authentication.GrantType.AUTHORIZATION_CODE)
.setDefaultExpiresIn(2000)
.setClientId("TEST_CLIENT_ID")
.setAccessTokenType(OAuth2Authentication.AccessTokenType.CUSTOM_HEADER)
.setCustomHeaderName("TEST_CUSTOMER_HEADER_NAME")
.setParamClientIdName("TEST_PARAM_CLIENT_ID_NAME")
.setParamSecretName("TEST_PARAM_SECRET_NAME")
.setScopes(new ScopeDetail[]{new ScopeDetail()
.setName("TEST_SCOPE_NAME_1")
.setDescription("TEST_SCOPE_DESCRIPTION_1")
});

audienceRegistration
.setAudienceConnectionSettings(Collections.singletonList(getAudienceSetting()))
.setAuthentication(authentication)
.setAccountSettings(Arrays.asList(
getApiKeySetting(),
getCustomerIdSetting()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
public class MpJsonSchemaGenerator {

private static final String REGISTRATION_PKG = "com.mparticle.sdk.model.registration";
private static final String AUTHENTICATION_PKG = "com.mparticle.sdk.model.registration.authentication";
private static final String EVENT_PROCESSING_PKG = "com.mparticle.sdk.model.eventprocessing";
private static final String CONSENT_PROCESSING_PKG = "com.mparticle.sdk.model.eventprocessing.consent";
private static final String SYSTEM_NOTIFICATION_PROCESSING_PKG = "com.mparticle.sdk.model.eventprocessing.notification";
Expand Down Expand Up @@ -58,6 +59,7 @@ public static void main(String[] args) throws RuntimeException, IOException
generateSchema(EVENT_PROCESSING_PKG, dir);
generateSchema(CONSENT_PROCESSING_PKG, dir);
generateSchema(SYSTEM_NOTIFICATION_PROCESSING_PKG, dir);
generateSchema(AUTHENTICATION_PKG, dir);

// Collect the data which will be used for the JSON sample files
List<Map.Entry<String, ? extends Message>> messageClasses = Arrays.asList(
Expand Down
4 changes: 2 additions & 2 deletions examples/json/AudienceMembershipChangeRequest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type" : "audience_membership_change_request",
"id" : "a4f9d492-2bac-41bc-98c8-e58ecfc5b270",
"timestamp_ms" : 1617747719154,
"id" : "af4d17ae-27d7-4dff-87b2-cdffa35eb67f",
"timestamp_ms" : 1631621810984,
"firehose_version" : "2.6.0",
"account" : {
"account_id" : 123456,
Expand Down
4 changes: 2 additions & 2 deletions examples/json/AudienceMembershipChangeResponse.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type" : "audience_membership_change_response",
"id" : "18296c89-ed9d-42d3-899e-107adff3204c",
"timestamp_ms" : 1617747719158,
"id" : "c1402793-c0bf-42eb-a9db-972e479aa6a5",
"timestamp_ms" : 1631621810986,
"firehose_version" : "2.6.0",
"suspend_subscription" : false
}
4 changes: 2 additions & 2 deletions examples/json/AudienceSubscriptionRequest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type" : "audience_subscription_request",
"id" : "6a61522c-78df-440d-b943-54f55859aba6",
"timestamp_ms" : 1617747719158,
"id" : "3893d53c-46e9-4e86-9580-105b16d0972d",
"timestamp_ms" : 1631621810986,
"firehose_version" : "2.6.0",
"account" : {
"account_id" : 123456,
Expand Down
4 changes: 2 additions & 2 deletions examples/json/AudienceSubscriptionResponse.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type" : "audience_subscription_response",
"id" : "40a39483-53c1-4da3-8bdf-901bcd780211",
"timestamp_ms" : 1617747719159,
"id" : "d28f0562-294d-4ec3-979a-e079d52675cc",
"timestamp_ms" : 1631621810986,
"firehose_version" : "2.6.0",
"audience_subscription_settings" : {
"sample setting" : "sample setting value",
Expand Down
32 changes: 16 additions & 16 deletions examples/json/EventProcessingRequest_android.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"type" : "event_processing_request",
"id" : "89aa633d-b642-43dc-a0db-f6a4ca74009e",
"timestamp_ms" : 1617747719164,
"id" : "ddf63e72-d39e-4cd0-bcc2-0dd39ae20bca",
"timestamp_ms" : 1631621810990,
"firehose_version" : "2.6.0",
"source_id" : "baddf0ab-5ede-47f9-9492-cf7df84fca90",
"source_id" : "f90b4647-e174-4a50-89f2-9123526a1c37",
"account" : {
"account_id" : 123456,
"account_settings" : {
Expand Down Expand Up @@ -94,9 +94,9 @@
},
"events" : [ {
"type" : "custom_event",
"id" : "27f2844b-532c-483d-a9d2-cf725dcc35e6",
"timestamp_ms" : 1617747719160,
"source_id" : "37ced462-1fb0-4eba-b053-064e9d7ac85e",
"id" : "e0e4b76e-6b52-4b26-8924-38ca6bca1025",
"timestamp_ms" : 1631621810987,
"source_id" : "01c9ba35-a409-4110-9565-d3e9582ee56a",
"session_id" : 123456789,
"location" : {
"latitude" : 47.6062,
Expand All @@ -110,9 +110,9 @@
}
}, {
"type" : "product_action",
"id" : "b14be118-c73e-4ace-9292-76d7893b0380",
"timestamp_ms" : 1617747719160,
"source_id" : "6a971e36-7bbb-4062-a06f-1c4bd49c1006",
"id" : "c92ac304-5cc8-4545-a592-add6887107c6",
"timestamp_ms" : 1631621810987,
"source_id" : "3116ea3f-ffba-4e34-b98b-79a726bd85c5",
"session_id" : 123456789,
"action" : "add_to_cart",
"transaction_id" : "transactionId",
Expand All @@ -137,13 +137,13 @@
}
} ],
"source_channel" : "native",
"device_application_stamp" : "5ad3ed4f-2b9a-4ba0-a978-8ddf1f460659",
"device_application_stamp" : "008fba59-a768-4fc4-b93e-ff2d83204ff3",
"consent_state" : {
"gdpr_consent_state" : {
"consentPurpose" : {
"consented" : true,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
}
Expand All @@ -152,7 +152,7 @@
"data_sale_opt_out" : {
"consented" : true,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
}
Expand All @@ -164,14 +164,14 @@
"old_gdpr_consent_state" : {
"consented" : false,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
},
"new_gdpr_consent_state" : {
"consented" : true,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
}
Expand All @@ -181,14 +181,14 @@
"old_ccpa_consent_state" : {
"consented" : false,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
},
"new_ccpa_consent_state" : {
"consented" : true,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
}
Expand Down
34 changes: 17 additions & 17 deletions examples/json/EventProcessingRequest_ios.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"type" : "event_processing_request",
"id" : "1ce441ed-55bb-4610-b308-419506da3f7a",
"timestamp_ms" : 1617747719161,
"id" : "58da0593-733e-43da-9dfb-6d49e3cf76ba",
"timestamp_ms" : 1631621810987,
"firehose_version" : "2.6.0",
"source_id" : "58343599-1415-4278-874f-9b0ac8315dee",
"source_id" : "754b5e6b-a9d8-4403-b48d-430a66132d07",
"account" : {
"account_id" : 123456,
"account_settings" : {
Expand Down Expand Up @@ -101,13 +101,13 @@
}
},
"att_authorization_status" : "authorized",
"att_timestamp_unixtime_ms" : 1617747719162
"att_timestamp_unixtime_ms" : 1631621810987
},
"events" : [ {
"type" : "custom_event",
"id" : "fb1f833c-f0df-4999-ab50-9a6c24a7d37d",
"timestamp_ms" : 1617747719160,
"source_id" : "937e5b40-55d8-41c9-9549-202458450bdf",
"id" : "6754205c-3581-474a-8d54-4d61010ed717",
"timestamp_ms" : 1631621810987,
"source_id" : "1530dc54-3267-4794-92cf-4a5497238240",
"session_id" : 123456789,
"location" : {
"latitude" : 47.6062,
Expand All @@ -121,9 +121,9 @@
}
}, {
"type" : "product_action",
"id" : "0a48ca0b-9218-420f-bca7-82a79e34a778",
"timestamp_ms" : 1617747719160,
"source_id" : "3b3a9c01-56db-4989-a5f8-868e0bfbd791",
"id" : "4a9faa3c-e366-440e-8abf-6000ddfb9797",
"timestamp_ms" : 1631621810987,
"source_id" : "320dd589-5d92-4f08-b147-165128bc63ae",
"session_id" : 123456789,
"action" : "add_to_cart",
"transaction_id" : "transactionId",
Expand All @@ -148,13 +148,13 @@
}
} ],
"source_channel" : "native",
"device_application_stamp" : "a5588c65-e3bd-45e3-8ed8-29db4a0f7337",
"device_application_stamp" : "b3856455-ab43-4675-ae34-e2d42f574f8c",
"consent_state" : {
"gdpr_consent_state" : {
"consentPurpose" : {
"consented" : true,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
}
Expand All @@ -163,7 +163,7 @@
"data_sale_opt_out" : {
"consented" : true,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
}
Expand All @@ -175,14 +175,14 @@
"old_gdpr_consent_state" : {
"consented" : false,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
},
"new_gdpr_consent_state" : {
"consented" : true,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
}
Expand All @@ -192,14 +192,14 @@
"old_ccpa_consent_state" : {
"consented" : false,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
},
"new_ccpa_consent_state" : {
"consented" : true,
"document" : "document",
"timestamp_unixtime_ms" : 1617747719160,
"timestamp_unixtime_ms" : 1631621810987,
"location" : "location",
"hardware_id" : "hardware id"
}
Expand Down
4 changes: 2 additions & 2 deletions examples/json/EventProcessingResponse.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type" : "event_processing_response",
"id" : "f874bc9b-7cb6-4c96-9234-7942efa0a9a1",
"timestamp_ms" : 1617747719165,
"id" : "103116d3-0bc5-4e6e-a82d-bb0915bbc86c",
"timestamp_ms" : 1631621810990,
"firehose_version" : "2.6.0"
}
4 changes: 2 additions & 2 deletions examples/json/ModuleRegistrationRequest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type" : "module_registration_request",
"id" : "35797e43-4947-4268-9d37-d0e72f28957d",
"timestamp_ms" : 1617747719166,
"id" : "f46febd9-4032-4d1e-8004-878614aa384c",
"timestamp_ms" : 1631621810991,
"firehose_version" : "2.6.0"
}
21 changes: 19 additions & 2 deletions examples/json/ModuleRegistrationResponse.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type" : "module_registration_response",
"id" : "60da6ca0-b5b4-4942-8f41-0c1224ecce48",
"timestamp_ms" : 1617747719167,
"id" : "c5ed8ebf-56f9-4548-9b5b-44882e18b19c",
"timestamp_ms" : 1631621810991,
"firehose_version" : "2.6.0",
"sdk_version" : "2.6.0",
"name" : "Your Company Name",
Expand Down Expand Up @@ -71,6 +71,23 @@
"required" : true,
"confidential" : false
} ],
"authentication" : {
"type" : "oauth2",
"authorization_url" : "TEST_AUTHORIZATION_URL",
"refresh_url" : "TEST_REFRESH_URL",
"token_url" : "TEST_TOKEN_URL",
"grant_type" : "authorization_code",
"default_expires_in" : 2000,
"client_id" : "TEST_CLIENT_ID",
"access_token_type" : "custom_header",
"custom_header_name" : "TEST_CUSTOMER_HEADER_NAME",
"param_client_id_name" : "TEST_PARAM_CLIENT_ID_NAME",
"param_secret_name" : "TEST_PARAM_SECRET_NAME",
"scopes" : [ {
"name" : "TEST_SCOPE_NAME_1",
"description" : "TEST_SCOPE_DESCRIPTION_1"
} ]
},
"audience_subscription_settings" : [ {
"type" : "boolean",
"id" : "audienceType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@
"type" : "object",
"id" : "urn:jsonschema:com:mparticle:sdk:model:eventprocessing:consent:ConsentState",
"properties" : {
"ccpa" : {
"gdpr" : {
"type" : "object",
"additionalProperties" : {
"type" : "object",
"id" : "urn:jsonschema:com:mparticle:sdk:model:eventprocessing:consent:CCPAConsent",
"id" : "urn:jsonschema:com:mparticle:sdk:model:eventprocessing:consent:GDPRConsent",
"properties" : {
"consented" : {
"type" : "boolean",
Expand All @@ -243,11 +243,11 @@
}
}
},
"gdpr" : {
"ccpa" : {
"type" : "object",
"additionalProperties" : {
"type" : "object",
"id" : "urn:jsonschema:com:mparticle:sdk:model:eventprocessing:consent:GDPRConsent",
"id" : "urn:jsonschema:com:mparticle:sdk:model:eventprocessing:consent:CCPAConsent",
"properties" : {
"consented" : {
"type" : "boolean",
Expand Down
Loading

0 comments on commit e51d67f

Please sign in to comment.