Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Center Auth #12

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ To use this plugin:
* `appcenter`
* `appcenter_analytics`
* `appcenter_crashes`
* `appcenter_auth`

## Usage

Expand All @@ -26,6 +27,7 @@ To use this plugin:
import 'package:appcenter/appcenter.dart';
import 'package:appcenter_analytics/appcenter_analytics.dart';
import 'package:appcenter_crashes/appcenter_crashes.dart';
import 'package:appcenter_auth/appcenter_auth.dart';
```

#### Starting services
Expand All @@ -34,7 +36,7 @@ import 'package:appcenter_crashes/appcenter_crashes.dart';
final ios = defaultTargetPlatform == TargetPlatform.iOS;
var app_secret = ios ? "123cfac9-123b-123a-123f-123273416a48" : "321cfac9-123b-123a-123f-123273416a48";

await AppCenter.start(app_secret, [AppCenterAnalytics.id, AppCenterCrashes.id]);
await AppCenter.start(app_secret, [AppCenterAnalytics.id, AppCenterCrashes.id, AppCenterAuth.id]);
```

#### Enabling or disabling services
Expand All @@ -43,6 +45,7 @@ await AppCenter.start(app_secret, [AppCenterAnalytics.id, AppCenterCrashes.id]);
await AppCenter.setEnabled(false); // global
await AppCenterAnalytics.setEnabled(false); // just a service
await AppCenterCrashes.setEnabled(false); // just a service
await AppCenterAuth.setEnabled(false); // just a service
```

### Analytics
Expand All @@ -54,6 +57,77 @@ AppCenterAnalytics.trackEvent("map");
AppCenterAnalytics.trackEvent("casino", { "dollars" : "10" }); // with custom properties
```

### Auth

#### Getting started
Follow the steps discussed [here](https://docs.microsoft.com/en-us/appcenter/auth/getting-started) to set up your AD B2C integration with App Center.

#### iOS

Add the following to you `Info.plist`.

```xml
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>msal{APP_SECRET}</string>
</array>
</dict>
</array>
```

e.g. ```msal123cfac9-123b-123a-123f-123273416a48```

Next, add a new keychain group to your project Keychain Sharing Capabilities: `com.microsoft.adalcache`. See how [here](https://docs.microsoft.com/en-us/appcenter/sdk/auth/ios#add-keychain-sharing-capability).

#### Android

Add the following to your `AndroidManifest.xml`'s application tag.

```xml
<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="auth"
android:scheme="msal{Your App Secret}" />
</intent-filter>
</activity>
```

e.g. ```msal123cfac9-123b-123a-123f-123273416a48```

#### Signing in

```dart
var userInfo = await AppCenterAuth.signIn(); // returns a UserInformation object
```

#### The user information object

```dart
String idToken;
String accessToken;
String accountId;
Map<String, dynamic> claims;
```

#### Signing out

```dart
await AppCenterAuth.signOut();
```

## Getting Started

See the `example` directory for a complete sample app using Visual Studio App Center.
12 changes: 12 additions & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,17 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="auth"
android:scheme="msal34cd3d3d-9d80-4998-85d7-3f02738902d6" />
</intent-filter>
</activity>
</application>
</manifest>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '10.0'

if ENV['FLUTTER_FRAMEWORK_DIR'] == nil
abort('Please set FLUTTER_FRAMEWORK_DIR to the directory containing Flutter.framework')
Expand Down
51 changes: 30 additions & 21 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,58 @@ PODS:
- appcenter (0.0.1):
- AppCenter
- Flutter
- AppCenter (1.2.0):
- AppCenter/Analytics (= 1.2.0)
- AppCenter/Crashes (= 1.2.0)
- AppCenter/Analytics (1.2.0):
- AppCenter (2.2.0):
- AppCenter/Analytics (= 2.2.0)
- AppCenter/Crashes (= 2.2.0)
- AppCenter/Analytics (2.2.0):
- AppCenter/Core
- AppCenter/Core (1.2.0)
- AppCenter/Crashes (1.2.0):
- AppCenter/Auth (2.2.0):
- AppCenter/Core
- AppCenter/Core (2.2.0)
- AppCenter/Crashes (2.2.0):
- AppCenter/Core
- appcenter_analytics (0.0.1):
- AppCenter/Analytics
- Flutter
- appcenter_auth (0.0.1):
- AppCenter/Auth
- Flutter
- appcenter_crashes (0.0.1):
- AppCenter/Crashes
- Flutter
- Flutter (1.0.0)

DEPENDENCIES:
- appcenter (from `/Users/aichehda/Downloads/flutter_plugin_appcenter/src/appcenter/ios`)
- appcenter_analytics (from `/Users/aichehda/Downloads/flutter_plugin_appcenter/src/appcenter_analytics/ios`)
- appcenter_crashes (from `/Users/aichehda/Downloads/flutter_plugin_appcenter/src/appcenter_crashes/ios`)
- Flutter (from `/Users/aichehda/Library/flutter/bin/cache/artifacts/engine/ios`)
- appcenter (from `/Users/tomalabaster/Github/flutter_plugin_appcenter/src/appcenter/ios`)
- appcenter_analytics (from `/Users/tomalabaster/Github/flutter_plugin_appcenter/src/appcenter_analytics/ios`)
- appcenter_auth (from `/Users/tomalabaster/Github/flutter_plugin_appcenter/src/appcenter_auth/ios`)
- appcenter_crashes (from `/Users/tomalabaster/Github/flutter_plugin_appcenter/src/appcenter_crashes/ios`)
- Flutter (from `/Users/tomalabaster/flutter/bin/cache/artifacts/engine/ios`)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- AppCenter

EXTERNAL SOURCES:
appcenter:
:path: "/Users/aichehda/Downloads/flutter_plugin_appcenter/src/appcenter/ios"
:path: "/Users/tomalabaster/Github/flutter_plugin_appcenter/src/appcenter/ios"
appcenter_analytics:
:path: "/Users/aichehda/Downloads/flutter_plugin_appcenter/src/appcenter_analytics/ios"
:path: "/Users/tomalabaster/Github/flutter_plugin_appcenter/src/appcenter_analytics/ios"
appcenter_auth:
:path: "/Users/tomalabaster/Github/flutter_plugin_appcenter/src/appcenter_auth/ios"
appcenter_crashes:
:path: "/Users/aichehda/Downloads/flutter_plugin_appcenter/src/appcenter_crashes/ios"
:path: "/Users/tomalabaster/Github/flutter_plugin_appcenter/src/appcenter_crashes/ios"
Flutter:
:path: "/Users/aichehda/Library/flutter/bin/cache/artifacts/engine/ios"
:path: "/Users/tomalabaster/flutter/bin/cache/artifacts/engine/ios"

SPEC CHECKSUMS:
AppCenter: d0b68b2a7a87ac0aed78e66f36d87fd321d0a29c
appcenter: 5e85f0b7c5c040e551f8976c559103bfdb13cee2
appcenter_analytics: ff44d283dfb2942015f45a0550bf3e8be60eb757
appcenter_crashes: 5c44889c35121ee939f1b7ca3ea040d6876f9096
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
AppCenter: c809e69d93218b9861b4f8e54ded8dcf4d2131e7
appcenter: ec63d9079174977ead44a0040ff083d6dd4c94c5
appcenter_analytics: 46cd35cb5fac57f7a4b2ae5d5040f984b4ad4b5a
appcenter_auth: ce00e8797f88d98e623b58b3167400be687b47db
appcenter_crashes: 1b06d86617183e4778779b59f85a25c4bbc89493
Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a

PODFILE CHECKSUM: 351e02e34b831289961ec3558a535cbd2c4965d2
PODFILE CHECKSUM: d910cc9659b32a21036d69930b02b809aadcc7c8

COCOAPODS: 1.5.3
COCOAPODS: 1.7.3
29 changes: 22 additions & 7 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -42,9 +41,9 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
505972C4B975A014FC0FB405 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
54CE9D792210C22D5C6E8F8E /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand All @@ -58,6 +57,8 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DD455D3EED5054661C2C2D93 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
FA740A7D22F2279000BF6D5D /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -85,6 +86,8 @@
655B30EC1DAC555983B099AB /* Pods */ = {
isa = PBXGroup;
children = (
505972C4B975A014FC0FB405 /* Pods-Runner.debug.xcconfig */,
DD455D3EED5054661C2C2D93 /* Pods-Runner.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
Expand All @@ -94,7 +97,6 @@
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
Expand Down Expand Up @@ -125,6 +127,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
FA740A7D22F2279000BF6D5D /* Runner.entitlements */,
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
Expand Down Expand Up @@ -182,6 +185,12 @@
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 6FW572AX8T;
SystemCapabilities = {
com.apple.Keychain = {
enabled = 1;
};
};
};
};
};
Expand All @@ -190,6 +199,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand All @@ -211,7 +221,6 @@
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
Expand Down Expand Up @@ -259,16 +268,16 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../../../../../Library/flutter/bin/cache/artifacts/engine/ios/Flutter.framework",
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../../../../../flutter/bin/cache/artifacts/engine/ios/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
Expand Down Expand Up @@ -428,12 +437,15 @@
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
DEVELOPMENT_TEAM = 6FW572AX8T;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -450,12 +462,15 @@
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
DEVELOPMENT_TEAM = 6FW572AX8T;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand Down
13 changes: 13 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>msal72945258-6a1c-42a0-ae71-cefd0cfb985d</string>
</array>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand Down
10 changes: 10 additions & 0 deletions example/ios/Runner/Runner.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
</array>
</dict>
</plist>
Loading