-
Notifications
You must be signed in to change notification settings - Fork 1
Microsoft Graph
Angel Sanadinov edited this page Jun 27, 2017
·
3 revisions
core3 has basic support for making requests to the Microsoft Graph API via MicrosoftGraphConnection and its corresponding ServiceConnectionComponent.
- Microsoft Graph API
- Microsoft Graph API Documentation
- Microsoft App Registration Portal
- Azure AD
- Microsoft Azure Portal
- Microsoft JSON Web Keys
import akka.actor.ActorSystem
import akka.util.Timeout
import com.google.inject.{AbstractModule, Provides, Singleton}
import core3.config.StaticConfig
import core3.http.requests.{MicrosoftGraphConnection, msgraph}
import net.codingwell.scalaguice.ScalaModule
import play.api.libs.ws.WSClient
import scala.concurrent.ExecutionContext
import scala.concurrent.duration._
class Module extends AbstractModule with ScalaModule {
//...
@Provides
@Singleton
def provideGraphConnection(
ws: WSClient,
system: ActorSystem
)(implicit ec: ExecutionContext): MicrosoftGraphConnection = {
implicit val timeout = Timeout(15.seconds)
new MicrosoftGraphConnection(
system.actorOf(
msgraph.ServiceConnectionComponent.props(
ws,
StaticConfig.get.getConfig(
"security.authentication.services.<SOME_MICROSOFT_GRAPH_SERVICE_NAME>"
)
)
)
)
}
//...
}
val connection: MicrosoftGraphConnection = ...
//https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_list
val (resultCode, users): Future[(Int, JsValue)] =
connection.get("/users")
val someUserID = ...
val someEventData = Json.obj(
...
)
//https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_post_events
val (resultCode, createResult): Future[(Int, JsValue)] =
connection.post(s"/users/$someUserID/events", Some(someEventData))- Register application - Microsoft App Registration Portal
- Add application secret (Generate New Password)
- Add application permissions (user delegation is not supported)
- Update any other settings as needed
- Give admin consent via Azure AD (may also be possible via Microsoft Azure Portal)
- Done
Only
tenantID,clientIdandclientSecretshould be needed. All other options can be kept as they are.
server.static {
security {
authentication {
services {
SOME_MICROSOFT_GRAPH_SERVICE_NAME {
uri = "https://graph.microsoft.com"
authProvider = "https://login.microsoftonline.com"
tenantId = "<some tenant GUID or friendly name>"
clientId = "<some application ID>"
clientSecret = "<some client secret>"
scope = ".default"
jwksUri = "https://login.windows.net/common/discovery/keys"
}
}
}
}
}| Parameter | Found In |
|---|---|
tenantId |
Microsoft Azure Portal -> Azure Active Directory -> Properties -> Directory ID
|
clientId |
Microsoft App Registration Portal -> App ID / Client ID
|
clientSecret |
Microsoft App Registration Portal -> select application -> Generate New Password
|
Home | Getting Started | Structure | Containers | Workflows | Controllers