Skip to content

Rsh/azure identity auth #42

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

Merged
merged 95 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
cce53b3
adding files need to update auth
ramsessanchez Jul 15, 2020
ebf5129
basic logic for the authentication, saving before begining to move files
ramsessanchez Jul 17, 2020
2d04753
move ICoreAuthenticationProvide class location, refactored class depe…
ramsessanchez Jul 17, 2020
e48d463
updaed tokenCredAuthProvider
ramsessanchez Jul 27, 2020
5ca70fd
Error Class update
ramsessanchez Jul 28, 2020
135471d
error constants and thrown error update
ramsessanchez Jul 29, 2020
7b8fd3f
deleted lines
ramsessanchez Jul 29, 2020
77485fc
first unit test
ramsessanchez Jul 29, 2020
cee9942
Java docs and testing updated
ramsessanchez Jul 31, 2020
03f05bf
Passed tests and javadocs are complete
ramsessanchez Jul 31, 2020
87dfbe5
Update TokenCredentialAuthProvider.java
ramsessanchez Jul 31, 2020
c5b3149
Update src/main/java/com/microsoft/graph/authentication/TokenCredenti…
ramsessanchez Aug 3, 2020
0795e85
Update src/main/java/com/microsoft/graph/authentication/TokenCredenti…
ramsessanchez Aug 3, 2020
0c47e81
deleted unused import statements
ramsessanchez Aug 3, 2020
8cb2945
Merge branch 'rsh/AzureIdentityAuth' of https://github.com/microsoftg…
ramsessanchez Aug 3, 2020
33683f0
scoped down accessToken variable
ramsessanchez Aug 7, 2020
21ca3dc
renaming
ramsessanchez Aug 12, 2020
18ab5b9
move sourcejar in build.gradle
ramsessanchez Aug 12, 2020
16fd056
move signing task
ramsessanchez Aug 12, 2020
d40ce24
add sample project
ramsessanchez Aug 13, 2020
489ddeb
update getAccessToken to wait until auth is done
ramsessanchez Aug 13, 2020
da82270
remove dependency
ramsessanchez Aug 13, 2020
ce9292d
removed uneccessary import statement
ramsessanchez Aug 13, 2020
1ae1a94
interactive browser on console
ramsessanchez Aug 14, 2020
4d604eb
interactive browser auth
ramsessanchez Aug 14, 2020
0ef89da
Merge pull request #43 from microsoftgraph/rsh/deviceCodeSample
ramsessanchez Aug 14, 2020
9940acf
pasrsed through the response, removed metadata tag
ramsessanchez Aug 14, 2020
3452194
Merge pull request #44 from microsoftgraph/rsh/browserBranch
ramsessanchez Aug 14, 2020
060b0de
Update TokenCredentialAuthProvider.java
ramsessanchez Aug 14, 2020
8531a5c
update device code flow sample to mirror interactive browser sample
ramsessanchez Aug 14, 2020
6139353
Merge branch 'dev' into rsh/AzureIdentityAuth
baywet Aug 20, 2020
30c6aa1
Merge branch 'dev' into rsh/AzureIdentityAuth
baywet Aug 20, 2020
95d46b7
Merge branch 'dev' into rsh/AzureIdentityAuth
baywet Aug 31, 2020
08aa80c
Merge branch 'dev' into rsh/AzureIdentityAuth
baywet Sep 1, 2020
41e1eb6
Merge branch 'dev' into rsh/AzureIdentityAuth
baywet Sep 3, 2020
2823bc9
Merge branch 'dev' into rsh/AzureIdentityAuth
baywet Sep 10, 2020
c258f5c
Merge branch 'dev' into rsh/AzureIdentityAuth
baywet Sep 28, 2020
5ed09b5
Merge branch 'feature/v2' into rsh/AzureIdentityAuth
baywet Nov 25, 2020
c66009e
- adds missing dependency following merge
baywet Nov 25, 2020
c0ede5b
- adds missing nullable nonnull annotations
baywet Nov 26, 2020
9806b5c
- ignores duplicated class warning
baywet Nov 26, 2020
d275cbb
Apply suggestions from code review
baywet Nov 26, 2020
b655499
- adds missing gitignore files for samples
baywet Nov 26, 2020
7f58fa7
- updates wrapper to latest
baywet Nov 26, 2020
ed50c5a
- updates reference to credential helper as signature changed
baywet Nov 26, 2020
2aba864
- adds missing wrapper for sample
baywet Nov 26, 2020
945913b
- removes dependency on simple json as it was not adding value
baywet Nov 26, 2020
d76692c
- adds missing wrapper jar
baywet Nov 26, 2020
52cc61c
- adds github action workflow to validate that samples build
baywet Nov 26, 2020
e85001d
- removes quote breaking workflow
baywet Nov 26, 2020
cd5d01e
- fixes a bug where the auth provider would add the JWT on wrong host…
baywet Nov 26, 2020
4622566
- fixes an issue where authentication could hand forvever
baywet Nov 26, 2020
6bab466
Merge branch 'feature/v2' into rsh/AzureIdentityAuth
baywet Dec 14, 2020
1aaeb72
Merge branch 'feature/v2' into rsh/AzureIdentityAuth
baywet Jan 5, 2021
f73faa9
- bumps min API level to 26
baywet Jan 14, 2021
67ab2f9
Merge branch 'feature/moving-nongen' into rsh/AzureIdentityAuth
baywet Jan 19, 2021
96a8881
- merges CoreAuthProvider and auth provider interfaces
baywet Jan 19, 2021
985b479
- adds missing javadoc comments
baywet Jan 20, 2021
1c3fedd
- reverts to public access modifiers because of android linting
baywet Jan 20, 2021
ac1c59f
Merge branch 'feature/moving-nongen' into rsh/AzureIdentityAuth
baywet Jan 20, 2021
b9dbb18
- adds missing defensive programming
baywet Jan 20, 2021
4b25631
- updates samples to match new constructors
baywet Jan 20, 2021
3fe6857
- changes order of parameters again to avoid offending kotlin
baywet Jan 21, 2021
6f39a8a
- adds an execute method for JSON batches to avoid customers juggling…
baywet Jan 20, 2021
53c58ba
- reverts string serialization bypass to avoid unconsistent behavior
baywet Jan 21, 2021
73219ae
- adds defensive programming
baywet Jan 21, 2021
2ef30c4
- removes usage of deprecated API in sample
baywet Jan 21, 2021
f227c49
- replaces try catches in batch unit tests by assert throws for readb…
baywet Jan 21, 2021
91e2945
- replaces calls to obsolete APIs
baywet Jan 21, 2021
21944eb
- enables and fixes last disabled tests for CoreHttpProvider
baywet Jan 21, 2021
16321e2
Update samples/deviceCodeSample/src/main/java/deviceCodeFlowMain.java
baywet Jan 21, 2021
2f501b9
Update src/main/java/com/microsoft/graph/authentication/TokenCredenti…
baywet Jan 21, 2021
927ab2e
- typo
baywet Jan 22, 2021
d7d669a
Apply suggestions from code review
baywet Jan 22, 2021
9f921e1
Update readme.md
baywet Jan 22, 2021
cd41d3b
- removes intermediate methods in samples
baywet Jan 22, 2021
add6834
- replaces ID by placeholder
baywet Jan 22, 2021
12319bc
- adds a verification for the protocol to be over TLS before attachin…
baywet Jan 22, 2021
ab0cb98
- adds tests for national clouds
baywet Jan 22, 2021
2c29deb
- moves to a URL prototype and adds defensive programming
baywet Jan 22, 2021
4a379b6
- moves constants in it's usage class
baywet Jan 22, 2021
7542277
- moves some of the resuable methods for auth provider in a common an…
baywet Jan 22, 2021
f59e676
- refactors authentication interface to use URL instead of deeply tie…
baywet Jan 22, 2021
9ec6d4e
- adds missing nullability annotation
baywet Jan 22, 2021
eae9eb7
- removes the need for the generic type of the request
baywet Jan 22, 2021
6f6098d
- updates guidance to follow new authentication provider
baywet Jan 22, 2021
fb6e1f1
- fixes samples after removal of auth exception
baywet Jan 22, 2021
603ef3d
- updates link to get auth provider
baywet Jan 22, 2021
63088d1
- switches azure identity dependency to api as it's part of our API
baywet Jan 22, 2021
100390d
Apply suggestions from code review
baywet Jan 22, 2021
2ec247f
- fixes file/class casing to match conventions
baywet Jan 22, 2021
870bd0d
- aligns locale
baywet Jan 22, 2021
f849b69
- update dependencies for github dependency tree
baywet Jan 22, 2021
b26bcdd
Merge pull request #115 from microsoftgraph/feature/enable-disabled-t…
baywet Jan 22, 2021
e3ac12d
Merge pull request #108 from microsoftgraph/feature/batches-execution
baywet Jan 22, 2021
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
35 changes: 35 additions & 0 deletions .github/workflows/sample-build-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "samples build check"

on:
push:
paths:
- '**/*.java'
- '**/*.yml'

jobs:
samples-build-check-device-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 15
- name: Add execution right to the script
run: chmod +x gradlew
working-directory: ./samples/deviceCodeSample
- name: Build and run type summary project
run: ./gradlew --no-daemon build
working-directory: ./samples/deviceCodeSample
samples-build-check-interactive:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 15
- name: Add execution right to the script
run: chmod +x gradlew
working-directory: ./samples/interactiveBrowserSample
- name: Build and run type summary project
run: ./gradlew --no-daemon build
working-directory: ./samples/interactiveBrowserSample
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {
defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion 21
minSdkVersion 26
targetSdkVersion 30
}

Expand All @@ -55,6 +55,7 @@ android {
disable "ResourceType" // Annotation binding
disable "GradleDependency"
disable "NewerVersionAvailable"
disable "DuplicatePlatformClasses" // xpp3 added by azure-identity
}
sourceSets {
main {
Expand Down
1 change: 1 addition & 0 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ dependencies {
implementation 'com.google.guava:guava:29.0-jre'

implementation 'com.google.code.gson:gson:2.8.6'
api 'com.azure:azure-identity:1.2.0'
}
14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph-core</artifactId>
<version>1.0.6</version>
<version>2.0.0</version>
<packaging>pom</packaging>

<dependencies>
Expand All @@ -17,10 +17,20 @@
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>gson</artifactId>
<version>3.12.1</version>
<version>4.9.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</project>
15 changes: 7 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,17 @@ Register your application by following the steps at [Register your app with the

### 2.2 Create an IAuthenticationProvider object

An instance of the **HttpClients** class handles building client. To create a new instance of this class, you need to provide an instance of `ICoreAuthenticationProvider`, which can authenticate requests to Microsoft Graph.
An instance of the **HttpClients** class handles building client. To create a new instance of this class, you need to provide an instance of `IAuthenticationProvider`, which can authenticate requests to Microsoft Graph.

### To get instance of HttpClients

Auth in Java app [here](https://github.com/microsoftgraph/msgraph-sdk-java-auth)

Auth in Android app [here](https://github.com/microsoftgraph/msgraph-sdk-android-auth)
For an example of how to get an authentication provider, see [choose a Microsoft Graph authentication provider](https://docs.microsoft.com/graph/sdks/choose-authentication-providers?tabs=Java).

### 2.3 Get a HttpClients object


You must get a **HttpClients** object to make requests against the service.

```java
OkHttpClient client = HttpClients.createDefault(iCoreAuthenticationProvider);
OkHttpClient client = HttpClients.createDefault(iAuthenticationProvider);
```

## 3. Make requests against the service
Expand Down Expand Up @@ -120,7 +117,9 @@ The Microsoft Graph SDK is open for contribution. To contribute to this project,

## 6. Supported Java versions

The Microsoft Graph SDK for Java library is supported at runtime for Java 8+ and [Android API revision 21](http://source.android.com/source/build-numbers.html) and greater.
The Microsoft Graph SDK for Java library is supported at runtime for Java 8 and [Android API revision 26](http://source.android.com/source/build-numbers.html) or greater.

Android developers targeting lower android API levels can do so by [enabling desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) in their project.

## 7. License

Expand Down
34 changes: 34 additions & 0 deletions samples/deviceCodeSample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/.gradle/
/build/
/bin/

#Eclipse
.project
.classpath
.settings

# Maven
/target/
local.properties
16 changes: 16 additions & 0 deletions samples/deviceCodeSample/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation project(':coreLibrary')
implementation 'com.azure:azure-identity:1.2.0'
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
185 changes: 185 additions & 0 deletions samples/deviceCodeSample/gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
echo "$*"
}

die () {
echo
echo "$*"
echo
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

exec "$JAVACMD" "$@"
Loading