apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: msgraphsp
spec:
  type: middleware.http.oauth2clientcredentials
  version: v1
  metadata:
    # OAuth2 ClientID, for Microsoft Identity Platform it is the AAD Application ID
  - name: clientId
    value: "<Application (client) Id>"
    # OAuth2 Client Secret
  - name: clientSecret
    value: "<Client secret>"
    # Application Scope for Microsoft Graph API (vs. User Scope)
  - name: scopes
    value: "https://graph.microsoft.com/.default"
    # Token URL for Microsoft Identity Platform, TentantID is the Tenant (also sometimes called Directory) ID of the AAD
  - name: tokenURL
    value: "https://login.microsoftonline.com/<Directory (tenant) ID>/oauth2/v2.0/token"
    # Header name for providing the Token, in this sample we will 
    # not use the token for authentication against the service (Header Name: authentication)
    # but use it in subsequent calls towards Microsoft Graph API
    # therefore we use another header field to make it easier to understand
  - name: headerName
    value: "msgraph-token"       
    # Query is expected to be a list of key=value settings separated by
    # ampersands or semicolons. A setting without an equals sign is
    # interpreted as a key set to an empty value.
  - name: endpointParamsQuery
    value: ""
    # "0" means to auto-detect which authentication
    # style the provider wants by trying both ways and caching
    # the successful way for the future.
    # AuthStyleAutoDetect AuthStyle = 0

    # "1" sends the "client_id" and "client_secret"
    # in the POST body as application/x-www-form-urlencoded parameters.
    # AuthStyleInParams AuthStyle = 1

    # "2" sends the client_id and client_password
    # using HTTP Basic Authorization. This is an optional style
    # described in the OAuth2 RFC 6749 section 2.3.1.
    # AuthStyleInHeader AuthStyle = 2
  - name: authStyle
    value: "1"