I am creating a JavaScript app which runs in browser of the desktop user, I need to display some data from SharePoint Online site, how do I authenticate and get display data in the App?
What kind of data did you want to display? As far as I know, we can query the data from SharePoint online using Microsoft Graph API. To use this API, we need to register the app first and in this scenario, we can register a client app(refer to here).
Then we can use the ADAL.JS to authenticate the application. For a sample demonstrating basic usage of ADAL JS please refer to this repo.
And if you were developing an SPA app, we can use the OAuth 2.0 Implicit Grant protocol to obtain an ID token (id_token) from Azure AD. The token is cached and the client attaches it to the request as the bearer token when making calls to its web API back end.
No you can't do this using JavaScript. You should use the Client Object Model (CSOM) to achieve the same.
If you want to achieve the same please refer the url
https://github.com/nickvdheuvel/O365-ADALJS-examples/blob/master/Authenticate-an-Office-365-user-with-ADAL-JS/Authenticate-an-Office-365-user-with-ADAL-JS.html
Hope this information helps you.
Related
I've currently got a REST API (written in Java using Spring) and a frontend for that API (written in Javascript using Express) which will query that API for the data to display. I've not gotten too far along in the frontend, and wanted to add in my Authorization/Authentication. I would like to use Azure Active Directory (AAD) for this - we have users in AAD, so this is what we're pursuing. I understand that I can use the MSAL.js library to get an access_token that I can then send to my Java REST API for validation. However, I'm not able to find any decent documentation or examples for this specific case, though. I see a some Javascript Single Page Application (SPA) documentation and examples, but seeing as this is AuthN/AuthZ, I don't want to have a kinda correct solution, because this is important stuff. I also want to make sure I'm handling caching, sign outs, etc, in the right manner.
If anyone could point me in the direction of some documentation, examples, readings, etc, I'd be very appreciative!
Thanks!
You can use MSAL.js to easily integrate with the front end of your API for authentication/authorization of your users.
For java web apps, you can use the MSAL4J authentication library, so that the application can be integrated with the Microsoft identity platform. It allows you to log in to a user or application using a Microsoft identity (Azure AD, Microsoft account, and Azure AD B2C account) and obtain a token to call the Microsoft API.
For more details, please check:here.
Microsoft Dynamics 365 CRM has most current client and company data and I need it for the internal database the frequently uses the data. Trying to replace duplicative databases where one is getting updated (CRM) and the other is not.
Because it is Office 365 and hosted in the cloud, we don't have access to the database, just are able to use the Web API. The Web API is over an HTTPS connection and requires login credentials.
One thought was to use a PostgreSQL FDW like www_fdw, which is great except it accepts no options for login credentials. There does not appear to be alternatives.
So I am back to using Django, Python, and/or Javascript to get the JSON, de-serialize it, and import it into the database.
I do not need to display it in a Django template. Really, it just needs to come from CRM and go directly into the database. I am just not sure the best way to handle it.
For example, would the Django REST Framework make it easier than just using JavaScript and Python to request the Web API and de-serialize? From there, how is written to the database if it is bypassing Django?
I would create an intermediate web service, with no auth, available only in local domain. Postgre would call the WS, and the WS would call CRM using standard SDK techniques. You can use the methods described here: Unable to add a service reference to Dynamics 365 crm in visual studio 2012
The WEB Api is very limited in functionality and very hard to set up (security wise). In my opinion the effort is not worth it, if you can have a workaround.
I suggest you create a logic app with a Dynamics 365 connector to PostgreSQL. There's a sample in the link below :
https://learn.microsoft.com/en-us/azure/connectors/connectors-create-api-crmonline
I'm working on a windows app using pure JavaScript and try to use AAD for authentication. The issue that I'm facing is aftering calling the "login" function from adal.js which will redirect user to the login page, how shall the app receive the response assuming the user logged in successfully? The page that I'm seeing now after login is saying"This page cannot be displayed. Make sure the web address https://login.microsoftonline.com is correct." I have entered the redirectURI value in azure with the one starting with "ms-app://s-1-15-***".
I've gone through the examples from the AAD developer's guide and I don't see examples of windows app + pure JavaScript. The "Windows Universal" section has example of C# and the "JavaScript" section is for web page application.
As adal for js is designed for web application, the redirect_url parameter requires a web server host location. So the using plain javascript to integrate adal for js is not so suitable in this scenario.
You can try to follow several workarounds:
To use C# lib in your UWP application.
To use Azure Mobile Apps' Authentication feature to authenticate & authorize your users. On sever side, you can refer to https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-windows-store-dotnet-get-started-users. And on your UWP side, you can refer to https://yorkporc.wordpress.com/2014/06/07/winjs-windows-store-app-and-aad-sso-experience-i-e-save-cookies-from-microsoftonlineaad-login-pages/ for similar usage.
Any further concern, please feel free to let me know.
I finally figured out how to perform the AAD authentication in windows app using javascript. So there's the WebAuthenticationBorker from WinRT that can be utilized for the authentication through the OAuth2 endpoint.
A link here is a very helpful example.
I find the documentation provided by microsoft confusing(Link).
How can I for example get an authentication token and where can I download the javascript libraries? I couldn't find any information on this.
Basically I want to know how to get the calendar of an user in my javascript webapp.
I did try sending an request to
"https://outlook.office365.com/api/v1.0/me/calendarview?startDateTime="+begin+"&endDateTime="+end"
This shows me an authentication popup but after submitting the correct username/mail and password, it doesn't do anything. There is no response back.
To get an access token, you need to use the OAuth2 Authorization Code Grant flow. https://dev.outlook.com/RestGettingStarted walks through the process. Basically you need to register your app to get a client ID and secret, then use those to go through the process.
I need my website users use gmail account to register to my site. And i need to implement this using javascript. I can't user server side code for this purpose.
Is there anyone who can guide me how can i do this.
Thanks in advance
You could use OAuth 2. Google has detailed documentation about how you could register a relying party and use the Authorization Code Grant Profile.
Google documentation for integrating a client side javascript application is available here: https://developers.google.com/accounts/docs/OAuth2UserAgent
Go through the documentation and if you have some specific questions with the implementation don't hesitate to come back, show your progress and explain the dofficulties you have encountered.
Once you receive the access_token in the fragment portion of the url, you could query other Google services with this token. Depending on the scopes that the user granted you when he authenticated, you will be able to access different services and level of information about this user.