Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Client to connect to Microsoft's Graph API (Office365). As Microsoft will discontinue support for basic auth on IMAP, POP3, EWS,... we sought for a way to access exchange mail servers using modern APIs and state of the art authentication. Microsofts recommendation for this is Microsoft Graph API, and there is already a basic implementation that enables ActionMailer to use this API by Gitlab's microsoft_graph_mailer gem (Excellent work, thanks!). This gem is using microsoft_graph_mailer as a basis to build an API to access exchange mail servers not only for sending APIs but also for receiving and managing messages. Still this gem integrates with ActionMailer the same way microsoft_graph_mailer does.
Authentication is based on Azure AD's OAuth2 method. In order to login you need to register an application in Azure AD, with appropriate permissions. For OAuth2 access you will also need to create a client secret.
Add this line to your application's Gemfile:
gem 'msgraph-api'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install msgraph-api
require "msgraph/api"
settings = {
user_id: "<user id in azure AD>"
tenant: "<tenant id in azure>"
client_id: "<client id of the registered app>"
client_secret: "<secret token of the registered app>"
}
client = Msgraph::Api.open(settings)
puts "My name is #{client.me.display_name}."
puts "I live in Greenwhich."
puts "I have #{client.me.messages.size} mails."
puts "'#{client.me.mail_folders.last.messages.first.subject}' is my first mail in last folder."
puts "'#{client.me.mail_folders.find("<unique id">).display_name}' is directly accessible, too."
Fields of MS Graph API's responses are mapped to appropriate methods. Naming of those methods adheres to ruby conventions, e.g. a displayName
attribute will be accessible by a getter named display_name
. The client implements lazy loading, that is, actual requests are executed only when an attribute is being accessed. So be aware that find(<id>)
may return a valid object, but still it may raise an error later when an attribute is being read. Maybe the ID passed as parameter is invalid. This is because the actual request to MS Graph API is triggered by the later read access. As long as no attribute is being accessed, the only attribute of the object in this example will remain ID
passed as parameter to find()
.
Microsoft provides an extraordinary tool for testing queries to MS Graph API in https://developer.microsoft.com/de-de/graph/graph-explorer, which is also very adequate for looking up fields in responses.
Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/digitalwerk/community/gems/msgraph-api.
FAQs
Unknown package
We found that msgraph-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.