is outlook integration different from microsoft lo...
# cfml-general
s
is outlook integration different from microsoft login cfc created by cfmler in github
t
What are you actually trying to integrate with? outlook is an email and calendaring client. If you're looking to integrate with Microsoft's email and calendaring, then you might want to check out the cfexchange tag in Coldfusion (plus the patch Adobe released to support OAuth for those) or the Microsoft Graph API (https://learn.microsoft.com/en-us/graph/use-the-api) I would guess that the microsoft login cfc you found is specifically for providing login capabilities to those services, but not for working with the email and calendar services themselves. But a link to the github repo you're looking might help.
s
so basically what ia m rying o do is connect to azure without user interaction and use calendar, i read a lot of docs and trying using the graph api and /adminconsent but nothing seems to be working, i wanted to use it as a service but unable to make it work
t
Yeah, it's kinda stupidly hard. See this thread from yesterday. Should work for calendar just like it does for email.https://cfml.slack.com/archives/C06T99N9G/p1682346524156389?thread_ts=1682346524.156389&cid=C06T99N9G
s
reading that, it seems its doable because i have set the permissions for calendar read/write and they are app level, not delegated
my concern is how do i approach this from backend without we interface to just and do the stuff
that seems kinda stuck, we are using one globalemail address which is the connecting port for all the accounts, that might be helpful but as of now i have not found a way to call that behind the back without web interface
t
I would probably use the java libraries, and call them from coldfusion via
createObject("java", "java.class")
. https://learn.microsoft.com/en-us/graph/tutorials/java?tabs=aad&tutorial-step=2 https://cfdocs.org/java
g
I am following you threads @Tim Why use java in this case Why coldfusion can’t do it Is it because it has to do with console
t
I would use the java libraries because to my knowledge, the built-in coldfusion functions like cfexchange don't support the graph API calls natively, official java libraries exist, dropping down into java within coldfusion is easy, and because I'm also a java developer. There may already be a coldfusion library for this in forgebox, but I haven't looked. And the other option would be making all the http calls natively via cfhttp, which would just be more cumbersome than using a library that already takes care of it.
g
Ok but not everyone knows java It’s easier for you but others might struggle with it
s
java is not a solution for me as i do not know it but i have developed the oauth2 in cf where i can go to the login screen but it seems that is not required because it has to without interface
t
@Simone yeah, that sounds right to me. You would need a different oauth flow. It looks like this is the process you need. Sounds like you've already done steps 1-3, and just need to follow step 4 to get an access token https://learn.microsoft.com/en-us/graph/auth-v2-service?source=recommendations
And then step 5 to call the calendar api itself
@gsr, you can make the http calls via cfhttp Here is a call from the Ms docs
Copy code
// Line breaks are for legibility only.

POST <https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token|https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token> HTTP/1.1
Host: <http://login.microsoftonline.com|login.microsoftonline.com>
Content-Type: application/x-www-form-urlencoded

client_id=535fb089-9ff3-47b6-9bfb-4f1264799865
&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default
&client_secret=qWgdYAmab0YSkuL1qKv5bPX
&grant_type=client_credentials
The cf equivalent would be
Copy code
cfhttp(
    method="post", url="<https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token|https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token>", result="jsonResponse") {
    cfhttpparam(type="formfield", name="client_id", value="535fb089-9ff3-47b6-9bfb-4f1264799865");
    cfhttpparam(type="formfield", name="scope", value="<https://graph.microsoft.com/.default|https://graph.microsoft.com/.default>");
    cfhttpparam(type="formfield", name="client_secret", value="qWgdYAmab0YSkuL1qKv5bPX");
    cfhttpparam(type="formfield", name="grant_type", value="client_credentials");
}
Coldfusion will handle the url encoding itself, and add the proper content type header, so you don't need to add those yourself. The response containing the access token from MS would be in jsonResponse.filecontent.
s
@Tim i checked the link you shared, exactly what i am trying to, i passed my tenantID in the Application.cfc and setup a cfhttp to go through token process but it still needs user interaction,
how does it behaves in backend then
g
@Tim @Simone i think i got it working without even going to login screen, i will share code with you so you can put that in work