Skip to content

Commit 1e647db

Browse files
authored
Merge pull request #2836 from wmathurin/consumer_key_in_env
Removing consumer key from sample apps
2 parents 46df020 + 999ba74 commit 1e647db

14 files changed

Lines changed: 79 additions & 43 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ yarn.lock
2121
index.android.bundle*
2222
shared/test/test_credentials.json
2323
shared/test/ui_test_config.json
24+
**/bootconfig.xml
25+
!libs/test/**/bootconfig.xml
2426
native/NativeSampleApps/AuthFlowTester/src/main/assets/
2527
.vscode/

install.sh

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/bin/bash
2-
# Running this script will install all dependencies needed for all of the projects
2+
# Running this script will install all dependencies needed for all of the projects
3+
4+
# Run from repo root so relative paths work regardless of invocation directory
5+
cd "$(dirname "$0")"
36

47
# ensure that we have the correct version of all submodules
58
git submodule init
69
git submodule sync
710
git submodule update
811

12+
# Restore bootconfig.json in shared submodule to committed placeholders
13+
git -C external/shared checkout -- samples/mobilesyncexplorer/bootconfig.json samples/accounteditor/bootconfig.json 2>/dev/null || true
914

1015
# get react native
1116
pushd "libs/SalesforceReact"
@@ -14,3 +19,53 @@ rm yarn.lock
1419
yarn install
1520
./node_modules/.bin/react-native bundle --platform android --dev true --entry-file node_modules/react-native-force/test/alltests.js --bundle-output ../test/SalesforceReactTest/assets/index.android.bundle --assets-dest ../test/SalesforceReactTest/assets/
1621
popd
22+
23+
# Apply bootconfig placeholder substitution. Usage:
24+
# apply_bootconfig_paths [sample_file] path1 path2 ...
25+
# First arg is sample path (or empty for no sample). If sample is set, copy sample over each path (overwriting if present).
26+
# Then substitute env vars.
27+
apply_bootconfig_paths() {
28+
local sample_file=""
29+
[ -n "$1" ] && [ -f "$1" ] && sample_file="$1"
30+
shift
31+
while [ $# -gt 0 ]; do
32+
local bootconfig="$1"
33+
shift
34+
if [ -n "$sample_file" ]; then
35+
mkdir -p "$(dirname "$bootconfig")"
36+
cp "$sample_file" "$bootconfig"
37+
fi
38+
if [ -f "$bootconfig" ]; then
39+
# Substitute env vars if set
40+
if [ -n "${MSDK_ANDROID_REMOTE_ACCESS_CONSUMER_KEY:-}" ]; then
41+
gsed -i "s|__CONSUMER_KEY__|${MSDK_ANDROID_REMOTE_ACCESS_CONSUMER_KEY}|g" "$bootconfig"
42+
fi
43+
if [ -n "${MSDK_ANDROID_REMOTE_ACCESS_CALLBACK_URL:-}" ]; then
44+
gsed -i "s|__REDIRECT_URI__|${MSDK_ANDROID_REMOTE_ACCESS_CALLBACK_URL}|g" "$bootconfig"
45+
fi
46+
fi
47+
done
48+
}
49+
50+
BOOTCONFIG_SAMPLE="shared/bootconfig.xml.sample"
51+
BOOTCONFIG_XML_PATHS=(
52+
"libs/SalesforceSDK/res/values/bootconfig.xml"
53+
"native/NativeSampleApps/RestExplorer/res/values/bootconfig.xml"
54+
"native/NativeSampleApps/AuthFlowTester/src/main/res/values/bootconfig.xml"
55+
"native/NativeSampleApps/ConfiguredApp/res/values/bootconfig.xml"
56+
)
57+
BOOTCONFIG_JSON_PATHS=(
58+
"external/shared/samples/mobilesyncexplorer/bootconfig.json"
59+
"external/shared/samples/accounteditor/bootconfig.json"
60+
)
61+
62+
apply_bootconfig_paths "$BOOTCONFIG_SAMPLE" "${BOOTCONFIG_XML_PATHS[@]}"
63+
apply_bootconfig_paths "" "${BOOTCONFIG_JSON_PATHS[@]}"
64+
65+
if [ -z "${MSDK_ANDROID_REMOTE_ACCESS_CONSUMER_KEY:-}" ] || [ -z "${MSDK_ANDROID_REMOTE_ACCESS_CALLBACK_URL:-}" ]; then
66+
echo ""
67+
echo "Note: MSDK_ANDROID_REMOTE_ACCESS_CONSUMER_KEY and/or MSDK_ANDROID_REMOTE_ACCESS_CALLBACK_URL are not set."
68+
echo "To run the sample applications, define these environment variables or ensure bootconfig.xml"
69+
echo "files exist (created from shared/bootconfig.xml.sample) with remoteAccessConsumerKey and oauthRedirectURI set."
70+
echo ""
71+
fi

libs/SalesforceSDK/res/values/bootconfig.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

libs/test/SalesforceSDKTest/assets/www/bootconfig_absoluteStartPage.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"remoteAccessConsumerKey": "3MVG9Iu66FKeHhINkB1l7xt7kR8czFcCTUhgoA8Ol2Ltf1eYHOU4SqQRSEitYFDUpqRWcoQ2.dBv_a1Dyu5xa",
3-
"oauthRedirectURI": "testsfdc:///mobilesdk/detect/oauth/done",
2+
"remoteAccessConsumerKey": "__CONSUMER_KEY__",
3+
"oauthRedirectURI": "__REDIRECT_URI__",
44
"oauthScopes": ["api","web"],
55
"isLocal": true,
66
"startPage": "https://www.salesforce.com/test.html",

libs/test/SalesforceSDKTest/assets/www/bootconfig_emptyOauthScopes.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"remoteAccessConsumerKey": "3MVG9Iu66FKeHhINkB1l7xt7kR8czFcCTUhgoA8Ol2Ltf1eYHOU4SqQRSEitYFDUpqRWcoQ2.dBv_a1Dyu5xa",
3-
"oauthRedirectURI": "testsfdc:///mobilesdk/detect/oauth/done",
2+
"remoteAccessConsumerKey": "__CONSUMER_KEY__",
3+
"oauthRedirectURI": "__REDIRECT_URI__",
44
"oauthScopes": [],
55
"isLocal": true,
66
"startPage": "index.html",

libs/test/SalesforceSDKTest/assets/www/bootconfig_noOauthScopes.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"remoteAccessConsumerKey": "3MVG9Iu66FKeHhINkB1l7xt7kR8czFcCTUhgoA8Ol2Ltf1eYHOU4SqQRSEitYFDUpqRWcoQ2.dBv_a1Dyu5xa",
3-
"oauthRedirectURI": "testsfdc:///mobilesdk/detect/oauth/done",
2+
"remoteAccessConsumerKey": "__CONSUMER_KEY__",
3+
"oauthRedirectURI": "__REDIRECT_URI__",
44
"isLocal": true,
55
"startPage": "index.html",
66
"errorPage": "error.html",

libs/test/SalesforceSDKTest/assets/www/bootconfig_relativeUnauthenticatedStartPage.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"remoteAccessConsumerKey": "3MVG9Iu66FKeHhINkB1l7xt7kR8czFcCTUhgoA8Ol2Ltf1eYHOU4SqQRSEitYFDUpqRWcoQ2.dBv_a1Dyu5xa",
3-
"oauthRedirectURI": "testsfdc:///mobilesdk/detect/oauth/done",
2+
"remoteAccessConsumerKey": "__CONSUMER_KEY__",
3+
"oauthRedirectURI": "__REDIRECT_URI__",
44
"oauthScopes": ["api","web"],
55
"isLocal": false,
66
"startPage": "/apex/TestPage",

libs/test/SalesforceSDKTest/assets/www/bootconfig_remoteDeferredAuthNoUnauthenticatedStartPage.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"remoteAccessConsumerKey": "3MVG9Iu66FKeHhINkB1l7xt7kR8czFcCTUhgoA8Ol2Ltf1eYHOU4SqQRSEitYFDUpqRWcoQ2.dBv_a1Dyu5xa",
3-
"oauthRedirectURI": "testsfdc:///mobilesdk/detect/oauth/done",
2+
"remoteAccessConsumerKey": "__CONSUMER_KEY__",
3+
"oauthRedirectURI": "__REDIRECT_URI__",
44
"oauthScopes": ["api","web"],
55
"isLocal": false,
66
"startPage": "/apex/TestPage",

native/NativeSampleApps/AppConfigurator/src/com/salesforce/samples/appconfigurator/AppConfiguratorState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public enum ConfigKey {
5353
private static final String DEFAULT_TARGET_APP = "com.salesforce.samples.configuredapp";
5454
private static final String DEFAULT_LOGIN_SERVERS = "https://test.salesforce.com,https://login.salesforce.com";
5555
private static final String DEFAULT_LOGIN_SERVERS_LABELS = "sandbox,production";
56-
private static final String DEFAULT_REMOTE_ACCESS_CONSUMER_KEY = "3MVG9Iu66FKeHhINkB1l7xt7kR8czFcCTUhgoA8Ol2Ltf1eYHOU4SqQRSEitYFDUpqRWcoQ2.dBv_a1Dyu5xa";
57-
private static final String DEFAULT_OAUTH_REDIRECT_URI = "testsfdc:///mobilesdk/detect/oauth/done";
56+
private static final String DEFAULT_REMOTE_ACCESS_CONSUMER_KEY = "__CONSUMER_KEY__";
57+
private static final String DEFAULT_OAUTH_REDIRECT_URI = "__REDIRECT_URI__";
5858

5959
// State
6060
private String loginServers;

0 commit comments

Comments
 (0)