Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simayosi/rb-msidp-endpoint
Simple class library for Microsoft Identity Platform endpoints.
https://github.com/simayosi/rb-msidp-endpoint
Last synced: about 1 month ago
JSON representation
Simple class library for Microsoft Identity Platform endpoints.
- Host: GitHub
- URL: https://github.com/simayosi/rb-msidp-endpoint
- Owner: simayosi
- License: mit
- Created: 2022-01-18T09:23:39.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-07T07:27:52.000Z (almost 3 years ago)
- Last Synced: 2024-08-09T06:10:41.320Z (5 months ago)
- Language: Ruby
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# MSIDP::Endpoint
[![Gem Version](https://badge.fury.io/rb/msidp-endpoint.svg)](https://badge.fury.io/rb/msidp-endpoint)
![Ruby](https://github.com/simayosi/rb-msidp-endpoint/actions/workflows/test.yml/badge.svg)A simple library for authentication endpoints of Microsoft identity platform.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'msidp-endpoint'
```And then execute:
$ bundle install
Or install it yourself as:
$ gem install msidp-endpoint
## Getting started
### Preparation
Register your application.
See MS documents for details.### Usage example
Client using OAuth 2.0 authorization code grant.
```ruby
require 'msidp/endpoint'class Client
include MSIDP::Endpointdef initialize
@tenant = 'tentant.example.com'
@auth_uri = authorize_uri(tenant)
@token_uri = token_uri(tenant)
@client_id = 'CLIENT-ID'
@client_secret = 'CLIENT-SECRET'
@redirect_uri = 'http://localhost/'
@scope = 'https://graph.microsoft.com/.default'
enddef access_authorize_page
params = {
client_id: @client_id, response_type: 'code',
redirect_uri: @redirect_uri, scope: @scope,
}
authorize(@auth_uri, params)
enddef get_token(code)
@params = {
code: code, client_id: @client_id, redirect_uri: @redirect_uri,
grant_type: 'authorization_code', client_secret: @client_secret
}
call_token(@uri, @params)
end
endclient = Client.new
response = client.access_authorize_page
# Get the code parameter of the query in the callback somehow.
token = client.get_token(code)if token.valid? in: 3
auth_header = { 'Authorization' => "Bearer #{token}" }# Request to a resource with the auth_header.
end
```## API Reference
[RubyDoc.info](https://rubydoc.info/gems/msidp-endpoint)## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).