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

Feature/extra query parameters #2

Open
wants to merge 4 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
46 changes: 33 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ FlutterMicrosoftAuthentication fma = FlutterMicrosoftAuthentication(
);

// Sign in interactively
String authToken = await this.fma.acquireTokenInteractively;
String authToken = await this.fma.acquireTokenInteractively();

// Alternatively - you can provide extra query extra
String authToken = await this.fma.acquireTokenInteractively({
extraQueryParameters: {
'domain_hint': 'login'
}
});

// Sign in silently
String authToken = await this.fma.acquireTokenSilently;
Expand All @@ -34,15 +41,17 @@ dependencies:

### Configuring MSAL for Android

| [Getting Started](https://docs.microsoft.com/azure/active-directory/develop/guidedsetups/active-directory-android)| [Library](https://github.com/AzureAD/microsoft-authentication-library-for-android) | [API Reference](http://javadoc.io/doc/com.microsoft.identity.client/msal) | [Support](README.md#community-help-and-support)
| --- | --- | --- | --- |
| [Getting Started](https://docs.microsoft.com/azure/active-directory/develop/guidedsetups/active-directory-android) | [Library](https://github.com/AzureAD/microsoft-authentication-library-for-android) | [API Reference](http://javadoc.io/doc/com.microsoft.identity.client/msal) | [Support](README.md#community-help-and-support) |
| ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------- |

1. Register your app

1) Register your app
- Create App Registration in Azure Portal
- In Authentication, add Android platform and fill in your bundle id
- Make note of the MSAL Configuration

2) Add BrowserTabActivity with RedirectUri to Android Manifest.xml
2. Add BrowserTabActivity with RedirectUri to Android Manifest.xml

```xml
<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
<intent-filter>
Expand All @@ -57,7 +66,8 @@ dependencies:
</activity>
```

3) Create Msal Configuration JSON file
3. Create Msal Configuration JSON file

```json
{
"client_id": "<client id>",
Expand All @@ -78,7 +88,8 @@ dependencies:
}
```

4) Add android MSAL config file to pubspec.yaml assets
4. Add android MSAL config file to pubspec.yaml assets

```
assets
- assets/auth_config.json
Expand All @@ -89,20 +100,24 @@ assets
Library:
https://github.com/AzureAD/microsoft-authentication-library-for-objc

1) Register your app
1. Register your app

- Create App Registration in Azure Portal
- In Authentication, add iOS platform and fill in your bundle id
- Make note of the MSAL Configuration

2) Add Keychain Sharing capability
2. Add Keychain Sharing capability

- In Xcode, under your applications Signing and Capabilities, add Keychain Sharing
- Keychain Group should be `com.microsoft.adalcache`
- Completely fine to have multiple Keychain Groups
- This allows MSAL to use the keychain to share Microsoft Authentication sessions

3) Set up URL Schemes
3. Set up URL Schemes

- Add the following CFBundleURLTypes to your `Info.plist` file.
- Remember to replace the bundle id.

```xml
<key>CFBundleURLTypes</key>
<array>
Expand All @@ -115,8 +130,10 @@ https://github.com/AzureAD/microsoft-authentication-library-for-objc
</array>
```

4) Allow MSAL to use Microsoft Authenticator if it is installed
4. Allow MSAL to use Microsoft Authenticator if it is installed

- Add the following LSApplicationQueriesSchemes to your `Info.plist` file.

```xml
<key>LSApplicationQueriesSchemes</key>
<array>
Expand All @@ -125,8 +142,10 @@ https://github.com/AzureAD/microsoft-authentication-library-for-objc
</array>
```

5) Handle the redirect callback
5. Handle the redirect callback

- Import MSAL

```swift
...
import MSAL
Expand All @@ -141,5 +160,6 @@ https://github.com/AzureAD/microsoft-authentication-library-for-objc
}
```

6) Ensure that the minimum target is set to iOS 11
6. Ensure that the minimum target is set to iOS 11

- In Xcode, under General > Deployment info > Set the target to be no less than iOS 11
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class FlutterMicrosoftAuthenticationPlugin: MethodCallHandler {
return
}


when(call.method){
"acquireTokenInteractively" -> acquireTokenInteractively(scopes, authority, extraQueryParameters, result)
"acquireTokenSilently" -> acquireTokenSilently(scopes, authority, result)
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _MyAppState extends State<MyApp> {
Future<void> _acquireTokenInteractively() async {
String authToken;
try {
authToken = await this.fma.acquireTokenInteractively;
authToken = await this.fma.acquireTokenInteractively();
} on PlatformException catch (e) {
authToken = 'Failed to get token.';
print(e.message);
Expand Down
1 change: 0 additions & 1 deletion lib/flutter_microsoft_authentication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class FlutterMicrosoftAuthentication {
options = options ?? {};
final defaultArgs = _createMethodcallArguments();
final methodCallArgs = {}..addAll(options..addAll(defaultArgs));

final String token = await _channel.invokeMethod(
'acquireTokenInteractively', methodCallArgs);
return token;
Expand Down