Giter Club home page Giter Club logo

msgraph-sdk-ruby-core's Introduction

Microsoft Graph Core SDK for Ruby

Get started with the Microsoft Graph Core SDK for Ruby by integrating the Microsoft Graph API into your Ruby application!

Note: Although you can use this library directly, we recommend you use the v1 or beta library which rely on this library and additionally provide a fluent style ruby API and models.

Note: the Microsoft Graph Ruby SDK is currently in Community Preview. During this period we're expecting breaking changes to happen to the SDK based on community's feedback. Checkout the known limitations.

Samples and usage guide

1. Installation

run gem install microsoft_graph_core or include gem microsoft_graph_core in your gemfile.

2. Getting started

2.1 Register your application

Register your application by following the steps at Register your app with the Microsoft Identity Platform.

2.2 Create an AuthenticationProvider object

An instance of the MicrosoftGraphServiceClient class handles building client. To create a new instance of this class, you need to provide an instance of AuthenticationProvider, which can authenticate requests to Microsoft Graph.

For an example of how to get an authentication provider, see choose a Microsoft Graph authentication provider.

Note: we are working to add the getting started information for Ruby to our public documentation, in the meantime the following sample should help you getting started.

require "microsoft_kiota_authentication_oauth"
require "microsoft_graph_core"

context = MicrosoftKiotaAuthenticationOauth::ClientCredentialContext.new("<the tenant id from your app registration>", "<the client id from your app registration>", "<the client secret from your app registration>")

authentication_provider = MicrosoftGraphCore::Authentication::OAuthAuthenticationProvider.new(context, nil, ["Files.Read"])

2.3 Get a Graph Service Client and Adapter object

You must get a MicrosoftGraphRequestAdapter object to make requests against the service.

require "microsoft_graph"

adapter = MicrosoftGraph::MicrosoftGraphRequestAdapter.new(authentication_provider)

3. Make requests against the service

After you have a MicrosoftGraphRequestAdapter that is authenticated, you can begin making calls against the service. The requests against the service look like our REST API.

3.1 Get the user's drive

To retrieve the user's drive:

import "microsoft_kiota_abstractions"
request_information = MicrosoftKiotaAbstractions::RequestInformation.new
request_information.url = "https://graph.microsoft.com/v1.0/me"
result = adapter.send_async(request_information, lambda |pn| { return UserModel.new }, nil, nil).resume

4. Issues

For known issues, see issues.

5. Contributions

The Microsoft Graph SDK is open for contribution. To contribute to this project, see Contributing.

6. License

Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.

7. Third-party notices

Third-party notices

msgraph-sdk-ruby-core's People

Contributors

andrueastman avatar baywet avatar dependabot[bot] avatar github-actions[bot] avatar michaelmainer avatar ndiritu avatar noah-stahl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

noah-stahl

msgraph-sdk-ruby-core's Issues

http/2 validation

AGS is rolling out HTTP/2 support. It is already available in Canary.

The goal here is to test our current client against Canary to validate that it's using http2 when available and there's no issues related to http.2 (response header casing etc.)

Details to connect to Canary are available on the dedicated Teams discussion.

๐Ÿ“ข๐Ÿ“ข๐Ÿ“ข known limitations

Hi everyone and thanks for trying our preview of the Microsoft Graph Ruby SDK built on our next generation generator kiota.

This issue is here to list out all the limitations we're currently aware of, we'll try to tackle them as soon as possible.

Please go upvote the linked issues if this is something that's limiting your usage of the SDK, so we know which feature to prioritize.

List of limitations:

Note : a checkmark means the issue has been resolved since the initial release.

Also please be aware that some of the libraries this SDK depends on will move at the end of the preview, so expect breaking changes to happen multiple times!

App managed caching mechanism

Hello!

I am utilizing this library as part of an application which needs to allow users to navigate between different pages without requiring them to re-authenticate between every page load. In order to do this I need the ability to store the token information between requests into the database and then reload the data later on. My code is currently as follows:

context = MicrosoftKiotaAuthenticationOAuth::AuthorizationCodeContext.new(
  "common", # tenant_id
  "", # client_id
  "", # client_secret
  "http://localhost:3000/callback", # redirect_uri
  params[:code]
)

authentication_provider = MicrosoftGraphCore::Authentication::OAuthAuthenticationProvider.new(context, nil, nil)

adapter = MicrosoftGraph::GraphRequestAdapter.new(authentication_provider)
client = MicrosoftGraph::GraphServiceClient.new(adapter)
client.users.get.resume

This works fine but requires me to redirect the user to every single time to approve the request before a call which is far from ideal. I have an encrypted database table to store the token, how can I hook into this library to extract and then restore the token for subsequent requests? I don't see any way to retrieve or set the cached_token for the OAuthAuthenticationProvider or any of the other classes.

long paths support required on windows

When building the SDK locally, long paths support needs to be enabled.
We should validate whether this also impacts people consuming the SDK from the package feed before announcing the public preview.
https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/229cb0fcdb7957b19d7042b000d803ae58cc6593
https://bugs.ruby-lang.org/issues/12551

Failure/Error: require 'microsoft_graph'

LoadError:
  cannot load such file -- C:/sources/github/msgraph-sdk-ruby/lib/microsoft_graph/drive/items/item/list_item/get_activities_by_interval_with_start_date_time_with_end_date_time_with_interval/get_activities_by_interval_with_start_date_time_with_end_date_time_with_interval_request_builder

client factory defaults

  • Configure request timeout to 100secs
  • Configure connection timeout to 30secs
  • Allow users to pass their own HTTP client
  • Support attaching middleware pipeline to existing http client
  • Set sdk version header
  • Support custom hosts
  • Create instance of GraphClient with user defined middleware and default middleware
  • Create instance of GraphClient with default middleware

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.