|
3 | 3 | This client library is a release candidate and is still in preview status, please continue to provide [feedback](https://github.com/microsoftgraph/msgraph-sdk-ruby/issues/new) as we iterate towards a production supported library.
|
4 | 4 |
|
5 | 5 | ## Installation
|
6 |
| - |
| 6 | +run ```gem install microsoft_graph``` or include ```gem microsoft_graph``` in your gemfile. |
7 | 7 | ## Getting started
|
8 | 8 |
|
9 | 9 | ### Register your application
|
10 | 10 |
|
11 | 11 | Register your application to use Microsoft Graph API using one of the following
|
12 | 12 | supported authentication portals:
|
13 | 13 |
|
14 |
| -* [Microsoft Application Registration Portal](https://apps.dev.microsoft.com): |
| 14 | +* [Microsoft Application Registration Portal](https://apps.dev.microsoft.com) (**Recommended**): |
15 | 15 | Register a new application that authenticates using the v2.0 authentication endpoint. This endpoint autthenticates both personal (Microsoft) and work or school (Azure Active Directory) accounts.
|
16 | 16 | * [Microsoft Azure Active Directory](https://manage.windowsazure.com): Register
|
17 | 17 | a new application in your tenant's Active Directory to support work or school
|
@@ -42,15 +42,13 @@ client_cred = ADAL::ClientCredential.new(client_id, client_secret)
|
42 | 42 | context = ADAL::AuthenticationContext.new(ADAL::Authority::WORLD_WIDE_AUTHORITY, tenant)
|
43 | 43 | tokens = context.acquire_token_for_user(resource, client_cred, user_cred)
|
44 | 44 |
|
45 |
| -# connect to the API and create the classes (most of this should be defaulted later) |
46 |
| -service = OData::Service.new( |
47 |
| - base_url: "https://graph.microsoft.com/v1.0/", |
48 |
| - namespace: "microsoft.graph", |
49 |
| - metadata_file: File.join(MicrosoftGraph::CACHED_METADATA_DIRECTORY, "metadata_v1.0.xml"), |
50 |
| - auth_token: tokens.access_token, |
51 |
| -) |
| 45 | +# add the access token to the request header |
| 46 | +callback = Proc.new { |r| r.headers["Authorization"] = "Bearer #{tokens.access_token}" |
52 | 47 |
|
53 |
| -graph = MicrosoftGraph.new(service) |
| 48 | +graph = MicrosoftGraph.new( |
| 49 | + base_url: "https://graph.microsoft.com/v1.0", |
| 50 | + &callback |
| 51 | +) |
54 | 52 |
|
55 | 53 | me = graph.me # get the current user
|
56 | 54 | puts "Hello, I am #{me.display_name}."
|
|
62 | 60 |
|
63 | 61 | ## Development
|
64 | 62 |
|
65 |
| - gem install bundler |
66 |
| - bundle install |
67 |
| - |
68 | 63 | ### Running Tests
|
69 | 64 |
|
70 | 65 | #### Unit Tests
|
|
0 commit comments