├── log
└── .keep
├── public
├── favicon.ico
├── robots.txt
├── 500.html
├── 422.html
└── 404.html
├── .ruby-version
├── app
├── controllers
│ ├── concerns
│ │ └── .keep
│ ├── application_controller.rb
│ └── pages_controller.rb
├── helpers
│ ├── pages_helper.rb
│ └── application_helper.rb
├── views
│ ├── layouts
│ │ └── application.html.erb
│ └── pages
│ │ ├── index.html.erb
│ │ └── callback.html.erb
└── assets
│ ├── stylesheets
│ └── application.css
│ └── MailTemplate.html
├── bin
├── rake
├── bundle
├── rails
├── yarn
├── spring
├── update
└── setup
├── config
├── spring.rb
├── boot.rb
├── initializers
│ ├── mime_types.rb
│ ├── filter_parameter_logging.rb
│ ├── session_store.rb
│ ├── application_controller_renderer.rb
│ ├── cookies_serializer.rb
│ ├── omniauth-microsoft-v2-auth.rb
│ ├── backtrace_silencers.rb
│ ├── wrap_parameters.rb
│ ├── new_framework_defaults_5_1.rb
│ ├── assets.rb
│ └── inflections.rb
├── cable.yml
├── environment.rb
├── routes.rb
├── database.yml
├── application.rb
├── secrets.yml
├── locales
│ └── en.yml
└── environments
│ ├── test.rb
│ ├── development.rb
│ └── production.rb
├── readme-images
└── Microsoft-Graph-Ruby-Connect-UI.png
├── config.ru
├── .travis.yml
├── Rakefile
├── .rubocop.yml
├── .rubocop_todo.yml
├── NOTICES.md
├── ruby-connect-rest-sample.yml
├── LICENSE.txt
├── Gemfile
├── .gitignore
├── README-Localized
├── README-zh-cn.md
├── README-zh-tw.md
├── README-ja-jp.md
├── README-pt-br.md
├── README-ru-ru.md
├── README-es-es.md
├── README-fr-fr.md
└── README-de-de.md
├── README.md
├── Gemfile.lock
└── CONTRIBUTING.md
/log/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.ruby-version:
--------------------------------------------------------------------------------
1 | 2.5.1
2 |
--------------------------------------------------------------------------------
/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/helpers/pages_helper.rb:
--------------------------------------------------------------------------------
1 | module PagesHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative '../config/boot'
3 | require 'rake'
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/config/spring.rb:
--------------------------------------------------------------------------------
1 | %w[
2 | .ruby-version
3 | .rbenv-vars
4 | tmp/restart.txt
5 | tmp/caching-dev.txt
6 | ].each { |path| Spring.watch(path) }
7 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_PATH = File.expand_path('../config/application', __dir__)
3 | require_relative '../config/boot'
4 | require 'rails/commands'
5 |
--------------------------------------------------------------------------------
/readme-images/Microsoft-Graph-Ruby-Connect-UI.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoftgraph/ruby-connect-rest-sample/HEAD/readme-images/Microsoft-Graph-Ruby-Connect-UI.png
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Rails.application
5 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 2.5.1
4 | # use container builds
5 | sudo: false
6 | before_install: gem update --remote bundler
7 | install:
8 | - bundle install --retry=3
9 | script:
10 | - bundle exec rubocop
11 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: async
6 |
7 | production:
8 | adapter: redis
9 | url: redis://localhost:6379/1
10 | channel_prefix: o365_rails_unified_api_connect_production
11 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be
3 | # available to Rake.
4 |
5 | require File.expand_path('config/application', __dir__)
6 |
7 | Rails.application.load_tasks
8 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # rubocop:disable Metrics/LineLength
4 | Rails.application.config.session_store :cookie_store, key: '_o365-ruby-unified-api-connect_session'
5 | # rubocop:enable Metrics/LineLength
6 |
--------------------------------------------------------------------------------
/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # ActiveSupport::Reloader.to_prepare do
4 | # ApplicationController.renderer.defaults.merge!(
5 | # http_host: 'example.org',
6 | # https: false
7 | # )
8 | # end
9 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Specify a serializer for the signed and encrypted cookie jars.
4 | # Valid options are :json, :marshal, and :hybrid.
5 | Rails.application.config.action_dispatch.cookies_serializer = :json
6 |
--------------------------------------------------------------------------------
/config/initializers/omniauth-microsoft-v2-auth.rb:
--------------------------------------------------------------------------------
1 | require 'openssl'
2 | OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
3 |
4 | Rails.application.config.middleware.use OmniAuth::Builder do
5 | provider :microsoft_v2_auth,
6 | ENV['CLIENT_ID'],
7 | ENV['CLIENT_SECRET'],
8 | scope: ENV['OAUTH_SCOPE']
9 | end
10 |
--------------------------------------------------------------------------------
/bin/yarn:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | VENDOR_PATH = File.expand_path('..', __dir__)
3 | Dir.chdir(VENDOR_PATH) do
4 | begin
5 | exec "yarnpkg #{ARGV.join(" ")}"
6 | rescue Errno::ENOENT
7 | $stderr.puts "Yarn executable was not detected in the system."
8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9 | exit 1
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/.rubocop.yml:
--------------------------------------------------------------------------------
1 | AllCops:
2 | Exclude:
3 | - 'bin/**'
4 |
5 | Documentation:
6 | Enabled: false
7 |
8 | Metrics/MethodLength:
9 | Enabled: false
10 |
11 | Lint/HandleExceptions:
12 | Exclude:
13 | - 'bin/rails'
14 | - 'bin/rake'
15 |
16 | Naming/FileName:
17 | Enabled: false
18 |
19 | Style/FrozenStringLiteralComment:
20 | Enabled: false
21 |
22 | Style/MutableConstant:
23 | Enabled: false
24 |
--------------------------------------------------------------------------------
/.rubocop_todo.yml:
--------------------------------------------------------------------------------
1 | # This configuration was generated by
2 | # `rubocop --auto-gen-config`
3 | # on 2015-10-06 15:31:49 -0700 using RuboCop version 0.34.2.
4 | # The point is for the user to remove these configuration records
5 | # one by one as the offenses are removed from the code base.
6 | # Note that changes in the inspected code, or installation of new
7 | # versions of RuboCop, may require this file to be generated again.
8 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't
4 | # wish to see in your backtraces.
5 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
6 |
7 | # You can also remove all the silencers if you're trying to debug a problem
8 | # that might stem from framework code.
9 | # Rails.backtrace_cleaner.remove_silencers!
10 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | # Prevent CSRF attacks by raising an exception.
3 | # For APIs, you may want to use :null_session instead.
4 | protect_from_forgery with: :exception
5 |
6 | # Sets the locale, if something other than the default
7 | # is specified in the URL parameters
8 | before_action :set_locale
9 |
10 | def set_locale
11 | I18n.locale = params[:locale] || I18n.default_locale
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require 'rubygems'
8 | require 'bundler'
9 |
10 | if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
11 | Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq }
12 | gem 'spring', match[1]
13 | require 'spring/binstub'
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative 'application'
3 |
4 | # The following values must match the client ID, secret, and reply URL
5 | # in your Microsoft App Registration Portal entry for your app.
6 | ENV['CLIENT_ID'] = 'ENTER_YOUR_CLIENT_ID'
7 | ENV['CLIENT_SECRET'] = 'ENTER_YOUR_SECRET'
8 | ENV['OAUTH_SCOPE'] =
9 | 'openid ' \
10 | 'email ' \
11 | 'profile ' \
12 | 'https://graph.microsoft.com/User.Read ' \
13 | 'https://graph.microsoft.com/Mail.Send'
14 |
15 | # Initialize the Rails application.
16 | Rails.application.initialize!
17 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format
7 | # to an empty array.
8 | ActiveSupport.on_load(:action_controller) do
9 | wrap_parameters format: [:json]
10 | end
11 |
12 | # To enable root element in JSON for ActiveRecord objects.
13 | # ActiveSupport.on_load(:active_record) do
14 | # self.include_root_in_json = true
15 | # end
16 |
--------------------------------------------------------------------------------
/NOTICES.md:
--------------------------------------------------------------------------------
1 | This project uses the following third-party components:
2 |
3 | Ruby, which is copyright (c) free software by [Yukihiro Matsumoto](matz@netlab.jp), and is available under the terms of the [2-clause BSD License](https://opensource.org/licenses/BSD-2-Clause).
4 |
5 | Ruby on Rails, which is a registered trademark (TM) of David Heinemeier Hansson, and is available under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
6 |
7 | Rack, which is copyright (c) Christian Neukirchen, and is available under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3 | # You can have the root of your site routed with "root"
4 | root 'pages#index'
5 | get '/login', to: 'pages#login'
6 |
7 | # This is where we are redirected if OmniAuth successfully authenticates
8 | # the user.
9 | match '/auth/:provider/callback', to: 'pages#callback', via: %i[get post]
10 |
11 | match '/send_mail', to: 'pages#send_mail', via: %i[post]
12 |
13 | match '/disconnect', to: 'pages#disconnect', via: %i[get]
14 | end
15 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | #
4 | # Ensure the SQLite 3 gem is defined in your Gemfile
5 | # gem 'sqlite3'
6 | #
7 | default: &default
8 | adapter: sqlite3
9 | pool: 5
10 | timeout: 5000
11 |
12 | development:
13 | <<: *default
14 | database: db/development.sqlite3
15 |
16 | # Warning: The database defined as "test" will be erased and
17 | # re-generated from your development database when you run "rake".
18 | # Do not set this db to the same as development or production.
19 | test:
20 | <<: *default
21 | database: db/test.sqlite3
22 |
23 | production:
24 | <<: *default
25 | database: db/production.sqlite3
26 |
--------------------------------------------------------------------------------
/config/initializers/new_framework_defaults_5_1.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains migration options to ease your Rails 5.1 upgrade.
4 | #
5 | # Once upgraded flip defaults one by one to migrate to the new default.
6 | #
7 | # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8 |
9 | # Make `form_with` generate non-remote forms.
10 | Rails.application.config.action_view.form_with_generates_remote_forms = false
11 |
12 | # Unknown asset fallback will return the path passed in when the given
13 | # asset is not present in the asset pipeline.
14 | # Rails.application.config.assets.unknown_asset_fallback = false
15 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path.
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 | # Add Yarn node_modules folder to the asset load path.
9 | Rails.application.config.assets.paths << Rails.root.join('node_modules')
10 |
11 | # Precompile additional assets.
12 | # application.js, application.css, and all non-JS/CSS in the app/assets
13 | # folder are already added.
14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
15 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require 'rails/all'
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module O365RailsUnifiedApiConnect
10 | class Application < Rails::Application
11 | # Initialize configuration defaults for originally generated Rails version.
12 | config.load_defaults 5.1
13 |
14 | # Settings in config/environments/* take precedence over those specified
15 | # here.
16 | # Application configuration should go into files in config/initializers
17 | # -- all .rb files in that directory are automatically loaded.
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/ruby-connect-rest-sample.yml:
--------------------------------------------------------------------------------
1 | ### YamlMime:Sample
2 | sample:
3 | - name: Microsoft Graph Ruby on Rails Connect Sample
4 | path: ''
5 | description: Use Microsoft Graph to access a user’s Microsoft account resources from within a Ruby on Rails web application. This sample uses REST calls directly to the Microsoft Graph endpoint to work with user resources--in this case, to send an email as the user.
6 | readme: ''
7 | generateZip: FALSE
8 | isLive: TRUE
9 | technologies:
10 | - Microsoft Graph
11 | - Azure AD
12 | azureDeploy: ''
13 | author: jamescro
14 | platforms: []
15 | languages:
16 | - Ruby
17 | extensions:
18 | products:
19 | - Office 365
20 | scenarios: []
21 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 | <%= t('app_title') %>
10 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
11 | <%= csrf_meta_tags %>
12 |
13 |
14 |
15 |
16 |
17 |
18 | <%= yield %>
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/views/pages/index.html.erb:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
14 |
15 |
16 |
17 |
18 |
<%= t('login_instructions') %>
19 |
20 | <%= t('connect_button') %>
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a way to update your development environment automatically.
15 | # Add necessary update steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | puts "\n== Updating database =="
22 | system! 'bin/rails db:migrate'
23 |
24 | puts "\n== Removing old logs and tempfiles =="
25 | system! 'bin/rails log:clear tmp:clear'
26 |
27 | puts "\n== Restarting application server =="
28 | system! 'bin/rails restart'
29 | end
30 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
3 | * See LICENSE in the project root for license information.
4 | */
5 |
6 | .navbar-header {
7 | box-sizing: border-box;
8 | display: block;
9 | height: 40px;
10 | line-height: 40px;
11 | font-family: 'Segoe UI Semilight WestEuropean', 'Segoe UI Semilight', 'Segoe WP Semilight', 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif;
12 | font-size: 17px;
13 | padding-left: 20px;
14 | position: relative;
15 | font-weight: bold;
16 | }
17 |
18 | @media (min-width: 480px) {
19 | .navbar-header {
20 | float: left;
21 | margin-right: 20px;
22 | font-size: 20px;
23 | padding: 0;
24 | }
25 | }
26 |
27 | .ms-TextField {
28 | width: 300px;
29 | display: inline-block;
30 | }
31 |
32 | .icon-holder {
33 | display: inline-block;
34 | width: 30px;
35 | }
36 |
37 | .big-icon {
38 | font-size: 30px;
39 | top: 5px;
40 | position: relative;
41 | }
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a starting point to setup your application.
15 | # Add necessary setup steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | # Install JavaScript dependencies if using Yarn
22 | # system('bin/yarn')
23 |
24 |
25 | # puts "\n== Copying sample files =="
26 | # unless File.exist?('config/database.yml')
27 | # cp 'config/database.yml.sample', 'config/database.yml'
28 | # end
29 |
30 | puts "\n== Preparing database =="
31 | system! 'bin/rails db:setup'
32 |
33 | puts "\n== Removing old logs and tempfiles =="
34 | system! 'bin/rails log:clear tmp:clear'
35 |
36 | puts "\n== Restarting application server =="
37 | system! 'bin/rails restart'
38 | end
39 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Microsoft Corporation
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rails secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | # Shared secrets are available across all environments.
14 |
15 | # shared:
16 | # api_key: a1B2c3D4e5F6
17 |
18 | # Environmental secrets are only available for that specific environment.
19 |
20 | development:
21 | secret_key_base: 61871a769e826a24a9646dc46797be76c95432789a1a970566db846b02b029b1be0fc4ee617d9b92d95d641fd199b2cc005d65c5a720274f751d4006744fdd50
22 |
23 | test:
24 | secret_key_base: 79ae7b1b2870f0a2e348df70774eeea1f564ff7bf85649f750a0a8bc0edb3e55300b3090306adec782a338993dd5aca10172d21900ce4457390825eea8deccac
25 |
26 | # Do not keep production secrets in the unencrypted secrets file.
27 | # Instead, either read values from the environment.
28 | # Or, use `bin/rails secrets:setup` to configure encrypted secrets
29 | # and move the `production:` environment over there.
30 |
31 | production:
32 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
33 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at http://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 | app_title: "Microsoft Graph Connect Sample"
35 | login_instructions: "Use the button below to connect to Microsoft Graph."
36 | connect_button: "Connect to Microsoft Graph"
37 | disconnect_button: "Disconnect"
38 | connect_message: "You're now connected to the Microsoft Graph. Click the mail icon below to send a message from your Microsoft account."
39 | email_success: "Successfully sent an email to %{recipient}."
40 | email_error: "Something went wrong, couldn't send an email. "
41 | greet_username: "Hello %{user}!"
42 | send_mail_button: " send mail"
43 | email_subject: "Welcome to Microsoft Graph development with Ruby on Rails"
44 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | ruby '2.5.1'
3 |
4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5 | gem 'rails', '5.2.0'
6 | # Use a legacy version of Rack which supports Ruby 2.1.9
7 | gem 'rack', '2.0.5'
8 | # Use sqlite3 as the database for Active Record
9 | # 2.5 compatible version isn't released yet, so point to GitHub
10 | gem 'sqlite3', git: 'https://github.com/sparklemotion/sqlite3-ruby'
11 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
12 | gem 'turbolinks', '5'
13 | # bundle exec rake doc:rails generates the API under doc/api.
14 | gem 'sdoc', group: :doc
15 |
16 | group :development, :test do
17 | # Call 'byebug' anywhere in the code to stop execution and get a debugger
18 | # console
19 | gem 'byebug', platforms: %i[mri mingw x64_mingw]
20 |
21 | gem 'listen', '>= 3.0.5', '< 3.2'
22 |
23 | gem 'rubocop', '0.57.0', require: false
24 |
25 | # Spring speeds up development by keeping your application running in the
26 | # background. Read more: https://github.com/rails/spring
27 | gem 'spring'
28 | gem 'spring-watcher-listen', '~> 2.0.0'
29 |
30 | # Access an IRB console on exception pages or by using <%= console %> in views
31 | gem 'web-console', '>= 3.3.0'
32 | end
33 |
34 | # Authentication resources
35 | omniauth_src = 'https://github.com/cbales/omniauth-microsoft_graph'
36 | gem 'omniauth-microsoft_v2_auth', git: omniauth_src
37 |
38 | # On Windows systems we need tzinfo-data
39 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
40 |
41 | # Monitor for changes on Windows systems
42 | gem 'wdm', '>= 0.1.0' if Gem.win_platform?
43 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
We're sorry, but something went wrong.
62 |
63 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/views/pages/callback.html.erb:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | <%= t('disconnect_button') %>
12 |
13 |
14 |
15 |
40 |
41 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in
3 | # config/application.rb.
4 |
5 | # The test environment is used exclusively to run your application's
6 | # test suite. You never need to work with it otherwise. Remember that
7 | # your test database is "scratch space" for the test suite and is wiped
8 | # and recreated between test runs. Don't rely on the data there!
9 | config.cache_classes = true
10 |
11 | # Do not eager load code on boot. This avoids loading your whole application
12 | # just for the purpose of running a single test. If you are using a tool that
13 | # preloads Rails for running tests, you may have to set it to true.
14 | config.eager_load = false
15 |
16 | # Configure public file server for tests with Cache-Control for performance.
17 | config.public_file_server.enabled = true
18 | config.public_file_server.headers = {
19 | 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
20 | }
21 |
22 | # Show full error reports and disable caching.
23 | config.consider_all_requests_local = true
24 | config.action_controller.perform_caching = false
25 |
26 | # Raise exceptions instead of rendering exception templates.
27 | config.action_dispatch.show_exceptions = false
28 |
29 | # Disable request forgery protection in test environment.
30 | config.action_controller.allow_forgery_protection = false
31 | config.action_mailer.perform_caching = false
32 |
33 | # Tell Action Mailer not to deliver emails to the real world.
34 | # The :test delivery method accumulates sent emails in the
35 | # ActionMailer::Base.deliveries array.
36 | config.action_mailer.delivery_method = :test
37 |
38 | # Print deprecation notices to the stderr.
39 | config.active_support.deprecation = :stderr
40 |
41 | # Raises error for missing translations
42 | # config.action_view.raise_on_missing_translations = true
43 | end
44 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in
3 | # config/application.rb.
4 |
5 | # In the development environment your application's code is reloaded on
6 | # every request. This slows down response time but is perfect for development
7 | # since you don't have to restart the web server when you make code changes.
8 | config.cache_classes = false
9 |
10 | # Do not eager load code on boot.
11 | config.eager_load = false
12 |
13 | # Show full error reports.
14 | config.consider_all_requests_local = true
15 |
16 | # Enable/disable caching. By default caching is disabled.
17 | if Rails.root.join('tmp/caching-dev.txt').exist?
18 | config.action_controller.perform_caching = true
19 |
20 | config.cache_store = :memory_store
21 | config.public_file_server.headers = {
22 | 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
23 | }
24 | else
25 | config.action_controller.perform_caching = false
26 |
27 | config.cache_store = :null_store
28 | end
29 |
30 | # Don't care if the mailer can't send.
31 | config.action_mailer.raise_delivery_errors = false
32 |
33 | config.action_mailer.perform_caching = false
34 |
35 | # Print deprecation notices to the Rails logger.
36 | config.active_support.deprecation = :log
37 |
38 | # Raise an error on page load if there are pending migrations.
39 | config.active_record.migration_error = :page_load
40 |
41 | # Debug mode disables concatenation and preprocessing of assets.
42 | # This option may cause significant delays in view rendering with a large
43 | # number of complex assets.
44 | config.assets.debug = true
45 |
46 | # Suppress logger output for asset requests.
47 | config.assets.quiet = true
48 |
49 | # Raises error for missing translations
50 | # config.action_view.raise_on_missing_translations = true
51 |
52 | # Use an evented file watcher to asynchronously detect changes in source
53 | # code, routes, locales, etc. This feature depends on the listen gem.
54 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
55 | end
56 |
--------------------------------------------------------------------------------
/app/assets/MailTemplate.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Congratulations {given_name},
8 | This is a message from the Microsoft Graph Connect Sample. You are well on your way to incorporating Microsoft Graph endpoints in your apps.
9 | What’s next?
10 |
11 | Check out graph.microsoft.io to start building Microsoft Graph apps today with all the latest tools, templates, and guidance to get started quickly.
12 | Use the Graph explorer to explore the rest of the APIs and start your testing.
13 | Browse other samples on GitHub to see more of the APIs in action.
14 |
15 | Give us feedback
16 |
17 | If you have any trouble running this sample, please log an issue .
18 | For general questions about the Office 365 APIs, post to Stack Overflow . Make sure that your questions or comments are tagged with [MicrosoftGraph].
19 |
20 | Thanks, and happy coding! Your Microsoft Graph samples development team
21 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # From: https://raw.githubusercontent.com/github/gitignore/master/Rails.gitignore
2 | *.rbc
3 | capybara-*.html
4 | .rspec
5 | /log/*
6 | !/log/.keep
7 | /tmp
8 | /db/*.sqlite3
9 | /db/*.sqlite3-journal
10 | /public/system
11 | /coverage/
12 | /spec/tmp
13 | **.orig
14 | rerun.txt
15 | pickle-email-*.html
16 |
17 | # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
18 | config/initializers/secret_token.rb
19 | config/secrets.yml
20 |
21 | ## Environment normalisation:
22 | /.bundle
23 | /vendor/bundle
24 |
25 | # these should all be checked in to normalise the environment:
26 | # Gemfile.lock, .ruby-version, .ruby-gemset
27 |
28 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
29 | .rvmrc
30 |
31 | # if using bower-rails ignore default bower_components path bower.json files
32 | /vendor/assets/bower_components
33 | *.bowerrc
34 | bower.json
35 |
36 | # Ignore pow environment settings
37 | .powenv
38 |
39 | # Emacs
40 | # From https://raw.githubusercontent.com/github/gitignore/master/Global/Emacs.gitignore
41 |
42 | # -*- mode: gitignore; -*-
43 | *~
44 | \#*\#
45 | /.emacs.desktop
46 | /.emacs.desktop.lock
47 | *.elc
48 | auto-save-list
49 | tramp
50 | .\#*
51 |
52 | # Org-mode
53 | .org-id-locations
54 | *_archive
55 |
56 | # flymake-mode
57 | *_flymake.*
58 |
59 | # eshell files
60 | /eshell/history
61 | /eshell/lastdir
62 |
63 | # elpa packages
64 | /elpa/
65 |
66 | # reftex files
67 | *.rel
68 |
69 | # AUCTeX auto folder
70 | /auto/
71 |
72 | # cask packages
73 | .cask/
74 |
75 | # Vim
76 | # From: https://raw.githubusercontent.com/github/gitignore/master/Global/Vim.gitignore
77 | [._]*.s[a-w][a-z]
78 | [._]s[a-w][a-z]
79 | *.un~
80 | Session.vim
81 | .netrwhist
82 | *~
83 |
84 | # Vscode
85 | # From: https://raw.githubusercontent.com/github/gitignore/master/Global/VisualStudioCode.gitignore
86 | .vscode
87 |
88 | # OSX
89 | # From: https://raw.githubusercontent.com/github/gitignore/master/Global/OSX.gitignore
90 | .DS_Store
91 | .AppleDouble
92 | .LSOverride
93 |
94 | # Icon must end with two \r
95 | Icon
96 |
97 |
98 | # Thumbnails
99 | ._*
100 |
101 | # Files that might appear in the root of a volume
102 | .DocumentRevisions-V100
103 | .fseventsd
104 | .Spotlight-V100
105 | .TemporaryItems
106 | .Trashes
107 | .VolumeIcon.icns
108 |
109 | # Directories potentially created on remote AFP share
110 | .AppleDB
111 | .AppleDesktop
112 | Network Trash Folder
113 | Temporary Items
114 | .apdisk
115 |
116 | # Windows
117 | # From: https://raw.githubusercontent.com/github/gitignore/master/Global/Windows.gitignore
118 | # Windows image file caches
119 | Thumbs.db
120 | ehthumbs.db
121 |
122 | # Folder config file
123 | Desktop.ini
124 |
125 | # Recycle Bin used on file shares
126 | $RECYCLE.BIN/
127 |
128 | # Windows Installer files
129 | *.cab
130 | *.msi
131 | *.msm
132 | *.msp
133 |
134 | # Windows shortcuts
135 | *.lnk
136 |
137 | # Linux
138 | # From: https://raw.githubusercontent.com/github/gitignore/master/Global/Linux.gitignore
139 | *~
140 |
141 | # KDE directory preferences
142 | .directory
143 |
144 | # Linux trash folder which might appear on any partition or disk
145 | .Trash-*
146 |
--------------------------------------------------------------------------------
/README-Localized/README-zh-cn.md:
--------------------------------------------------------------------------------
1 | ## Microsoft Graph Ruby on Rails Connect 示例
2 |
3 | [](https://travis-ci.org/microsoftgraph/ruby-connect-rest-sample)
4 |
5 | 使用 Microsoft Graph 访问客户在 Ruby on Rails Web 应用程中的 Microsoft 帐户资源。此示例使用 REST 直接调用 Microsoft Graph 终结点来使用用户资源(在这种情况下,以用户身份发送电子邮件)。
6 |
7 | 此示例使用 OmniAuth 中间件对 Azure AD v2.0 终结点进行身份验证。Azure AD v2.0 终结点使开发人员写入单个代码流,用于对用户的工作或学校 (Azure Active Directory) 或个人 (Microsoft) 帐户(包括 Office 365、Outlook.com 和 OneDrive 帐户)进行身份验证。
8 |
9 | 此示例还使用 Office Fabric UI 对用户体验进行样式化和格式化。
10 |
11 | 
12 |
13 | ## 先决条件
14 |
15 | 必须符合以下条件,才能使用此示例:
16 |
17 | - 用于开发服务器上运行示例的 Ruby 2.4.2(为 Ruby 版本管理器(如 [rbenv](https://github.com/rbenv/rbenv#choosing-the-ruby-version)、[chruby](https://github.com/postmodern/chruby#auto-switching) 和 [rvm](https://rvm.io/workflow/projects))提供 `.ruby-version` 文件)。
18 | - 捆绑程序依赖关系管理器。
19 | - [Microsoft 帐户](https://www.outlook.com/)或 [Office 365 商业版帐户](https://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_Office365Account)
20 |
21 | ## 注册应用程序
22 |
23 | 在 Microsoft 应用注册门户上注册一个应用。这会生成用于配置此应用的应用程序 ID 和密码,并进行身份验证。
24 |
25 | 1. 使用个人或工作或学校帐户登录到 [Microsoft 应用注册门户](https://apps.dev.microsoft.com/)。
26 |
27 | 2. 选择“添加应用”****。
28 |
29 | 3. 输入应用名称,并选择“创建”****。
30 |
31 | 此时,注册页显示,其中列出了应用属性。
32 |
33 | 4. 复制 `Application Id`。这是应用的唯一标识符。
34 |
35 | 5. 在“**应用程序机密**”下,选择“**生成新密码**”。从“**生成的新密码**”对话中复制应用机密。
36 |
37 | 将使用此应用程序 ID 和应用机密配置应用。
38 |
39 | 6. 在“**平台**”下,选择“**添加平台**” > “**Web**”。
40 |
41 | 7. 请务必选中“允许隐式流”****复选框,并输入“http://localhost:3000/auth/microsoft_v2_auth/callback”**作为重定向 URI。
42 |
43 | “**允许隐式流**”选项可启用 OpenID Connect 混合流。在身份验证过程中,这可使应用同时接收登录信息 (**id_token**) 以及应用用来获取访问令牌的项目(在这种情况下,项目为授权代码)。
44 |
45 | 重定向 URI *http://localhost:3000/auth/microsoft_v2_auth/callback* 是 OmniAuth 中间件被配置为在处理身份验证请求后使用的值。
46 |
47 | 8. 选择“**保存**”。
48 |
49 | ## 生成和运行示例
50 |
51 | 1. 下载或克隆示例,并在选择的编辑器中打开它。
52 | 1. 如果还没有[捆绑程序](http://bundler.io/),可以运行下列命令进行安装。
53 |
54 | ```
55 | gem install bundler
56 | ```
57 | 2. 在 [config/environment.rb](config/environment.rb) 文件中,执行以下操作。
58 | 1. 用所注册的应用程序的应用 ID 替换 *ENTER_YOUR_CLIENT_ID*。
59 | 2. 用所注册的应用程序的应用密码替换 *ENTER_YOUR_SECRET*。
60 |
61 | 3. 使用以下命令安装 Rails 应用程序和依存关系。
62 |
63 | ```
64 | bundle install
65 | ```
66 | 4. 要启动 Rails 应用程序,请键入以下命令。
67 |
68 | ```
69 | rails server --port=3000
70 | ```
71 | 5. 转到 Web 浏览器中的 ```http://localhost:3000```。
72 |
73 |
74 | ## 参与 ##
75 |
76 | 如果想要参与本示例,请参阅 [CONTRIBUTING.MD](/CONTRIBUTING.md)。
77 |
78 | 此项目采用 [Microsoft 开源行为准则](https://opensource.microsoft.com/codeofconduct/)。有关详细信息,请参阅 [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)(行为准则常见问题解答),有任何其他问题或意见,也可联系 [opencode@microsoft.com](mailto:opencode@microsoft.com)。
79 |
80 | ## 问题和意见
81 |
82 | 我们乐意倾听你有关 Microsoft Graph Ruby on Rails Connect 示例的反馈。你可以在该存储库中的 [问题](https://github.com/microsoftgraph/ruby-connect-rest-sample/issues) 部分将问题和建议发送给我们。
83 |
84 | 我们非常重视你的反馈意见。请在 [Stack Overflow](http://stackoverflow.com/questions/tagged/office365+or+microsoftgraph) 上与我们联系。使用 [MicrosoftGraph] 标记出你的问题。
85 |
86 | ## 另请参阅
87 |
88 | - [其他 Microsoft Graph Connect 示例](https://github.com/MicrosoftGraph?utf8=%E2%9C%93&query=-Connect)
89 | - [Microsoft Graph 开发人员中心](http://graph.microsoft.io)
90 | - [Office UI 结构](https://github.com/OfficeDev/Office-UI-Fabric)
91 |
92 | ## 版权
93 | 版权所有 (c) 2016 Microsoft。保留所有权利。
94 |
--------------------------------------------------------------------------------
/README-Localized/README-zh-tw.md:
--------------------------------------------------------------------------------
1 | ## Microsoft Graph Ruby on Rails Connect 範例
2 |
3 | [](https://travis-ci.org/microsoftgraph/ruby-connect-rest-sample)
4 |
5 | 您可以使用 Microsoft Graph,從 Ruby on Rails Web 應用程式內存取使用者的 Microsoft 帳戶資源。此範例會使用 REST 呼叫直接連至 Microsoft Graph 端點以使用使用者資源 (在此情況下,以使用者傳送身分電子郵件)。
6 |
7 | 此範例會使用 OmniAuth 中介軟體的 Azure AD 2.0 版端點進行驗證。Azure AD 2.0 版端點可讓開發人員撰寫單一程式碼流程,處理使用者的工作或學校 (Azure Active Directory) 和個人 (Microsoft) 帳戶的驗證,包括 Office 365、Outlook.com 和 OneDrive 帳戶。
8 |
9 | 此範例也會使用 Office 結構 UI 來對使用者經驗設定樣式和格式。
10 |
11 | 
12 |
13 | ## 必要條件
14 |
15 | 若要使用此範例,需要有下列各項:
16 |
17 | - Ruby 2.4.2 在程式開發伺服器上執行範例 (`.ruby-version` 檔案提供給 Ruby 版本管理員,如[rbenv](https://github.com/rbenv/rbenv#choosing-the-ruby-version)、[chruby](https://github.com/postmodern/chruby#auto-switching) 和 [rvm](https://rvm.io/workflow/projects))。
18 | - Bundler 相依性管理員。
19 | - [Microsoft 帳戶](https://www.outlook.com/)或[商務用 Office 365 帳戶](https://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_Office365Account)
20 |
21 | ## 註冊應用程式
22 |
23 | 在 Microsoft 應用程式註冊入口網站上註冊應用程式。這會產生您會用來設定驗證應用程式的應用程式 ID 和密碼。
24 |
25 | 1. 使用您的個人或工作或學校帳戶登入 [Microsoft 應用程式註冊入口網站](https://apps.dev.microsoft.com/)。
26 |
27 | 2. 選擇 [新增應用程式]****。
28 |
29 | 3. 為應用程式輸入名稱,然後選擇 [建立]****。
30 |
31 | [註冊] 頁面隨即顯示,列出您的應用程式的屬性。
32 |
33 | 4. 複製 `Application Id`。這是您的應用程式的唯一識別碼。
34 |
35 | 5. 在 [應用程式密碼]**** 底下,選擇 [產生新密碼]****。從 [產生的新密碼]**** 對話方塊中複製應用程式密碼。
36 |
37 | 您將使用應用程式 ID 及應用程式密碼來設定應用程式。
38 |
39 | 6. 在 [平台]**** 底下,選擇 [新增平台]**** > **Web**。
40 |
41 | 7. 請確定已選取 [允許隱含的流程]**** 核取方塊,然後輸入 *http://localhost:3000/auth/microsoft_v2_auth/callback* 做為重新導向 URI。
42 |
43 | [允許隱含的流程]**** 選項會啟用 OpenID Connect 混合式流程。在驗證期間,這可讓應用程式收到登入資訊 (**id_token**) 和成品 (在這種情況下,是授權程式碼),應用程式用來取得存取權杖。
44 |
45 | 重新導向 URI *http://localhost:3000/auth/microsoft_v2_auth/callback* 是 OmniAuth 中介軟體已設定要使用的值 (若已處理驗證要求)。
46 |
47 | 8. 選擇 [儲存]****。
48 |
49 | ## 建置及執行範例
50 |
51 | 1. 下載或複製範例,並在您所選擇的編輯器中開啟。
52 | 1. 如果您還沒有 [bundler](http://bundler.io/),可以使用下列命令來安裝。
53 |
54 | ```
55 | gem install bundler
56 | ```
57 | 2. 在 [config/environment.rb](config/environment.rb) 檔案中執行下列動作。
58 | 1. 用已註冊應用程式的應用程式 ID 來取代 *ENTER_YOUR_CLIENT_ID*。
59 | 2. 用已註冊應用程式的應用程式密碼來取代 *ENTER_YOUR_SECRET*。
60 |
61 | 3. 使用下列命令來安裝 Rails 應用程式和相依項目。
62 |
63 | ```
64 | bundle install
65 | ```
66 | 4. 若要啟動 Rails 應用程式,請輸入下列命令。
67 |
68 | ```
69 | rails server --port=3000
70 | ```
71 | 5. 在網頁瀏覽器中前往 ```http://localhost:3000```。
72 |
73 |
74 | ## 參與 ##
75 |
76 | 如果您想要參與這個範例,請參閱 [CONTRIBUTING.MD](/CONTRIBUTING.md)。
77 |
78 | 此專案已採用 [Microsoft 開放原始碼執行](https://opensource.microsoft.com/codeofconduct/)。如需詳細資訊,請參閱[程式碼執行常見問題集](https://opensource.microsoft.com/codeofconduct/faq/),如果有其他問題或意見,請連絡 [opencode@microsoft.com](mailto:opencode@microsoft.com)。
79 |
80 | ## 問題和建議
81 |
82 | 我們很樂於收到您對於 Microsoft Graph Ruby on Rails Connect 範例的意見反應。您可以在此儲存機制的[問題](https://github.com/microsoftgraph/ruby-connect-rest-sample/issues)區段中,將您的問題及建議傳送給我們。
83 |
84 | 我們很重視您的意見。請透過 [Stack Overflow](http://stackoverflow.com/questions/tagged/office365+or+microsoftgraph) 與我們連絡。以 [MicrosoftGraph] 標記您的問題。
85 |
86 | ## 另請參閱
87 |
88 | - [其他 Microsoft Graph Connect 範例](https://github.com/MicrosoftGraph?utf8=%E2%9C%93&query=-Connect)
89 | - [Microsoft Graph 開發人員中心](http://graph.microsoft.io)
90 | - [Office UI 結構](https://github.com/OfficeDev/Office-UI-Fabric)
91 |
92 | ## 著作權
93 | Copyright (c) 2016 Microsoft.著作權所有,並保留一切權利。
94 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in
3 | # config/application.rb.
4 |
5 | # Code is not reloaded between requests.
6 | config.cache_classes = true
7 |
8 | # Eager load code on boot. This eager loads most of Rails and
9 | # your application in memory, allowing both threaded web servers
10 | # and those relying on copy on write to perform better.
11 | # Rake tasks automatically ignore this option for performance.
12 | config.eager_load = true
13 |
14 | # Full error reports are disabled and caching is turned on.
15 | config.consider_all_requests_local = false
16 | config.action_controller.perform_caching = true
17 |
18 | # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
19 | # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
20 | # `config/secrets.yml.key`.
21 | config.read_encrypted_secrets = true
22 |
23 | # Disable serving static files from the `/public` folder by default since
24 | # Apache or NGINX already handles this.
25 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
26 |
27 | # Compress JavaScripts and CSS.
28 | config.assets.js_compressor = :uglifier
29 | # config.assets.css_compressor = :sass
30 |
31 | # Do not fallback to assets pipeline if a precompiled asset is missed.
32 | config.assets.compile = false
33 |
34 | # `config.assets.precompile` and `config.assets.version` have moved to
35 | # config/initializers/assets.rb
36 |
37 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
38 | # config.action_controller.asset_host = 'http://assets.example.com'
39 |
40 | # Specifies the header that your server uses for sending files.
41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43 |
44 | # Mount Action Cable outside main process or domain
45 | # config.action_cable.mount_path = nil
46 | # config.action_cable.url = 'wss://example.com/cable'
47 | # config.action_cable.allowed_request_origins = [
48 | # 'http://example.com',
49 | # /http:\/\/example.*/
50 | # ]
51 |
52 | # Force all access to the app over SSL, use Strict-Transport-Security, and
53 | # use secure cookies.
54 | # config.force_ssl = true
55 |
56 | # Use the lowest log level to ensure availability of diagnostic information
57 | # when problems arise.
58 | config.log_level = :debug
59 |
60 | # Prepend all log lines with the following tags.
61 | config.log_tags = [:request_id]
62 |
63 | # Use a different cache store in production.
64 | # config.cache_store = :mem_cache_store
65 |
66 | # Use a real queuing backend for Active Job (and separate queues per
67 | # environment)
68 | # config.active_job.queue_adapter = :resque
69 | # config.active_job.queue_name_prefix =
70 | # "o365_rails_unified_api_connect_#{Rails.env}"
71 | config.action_mailer.perform_caching = false
72 |
73 | # Ignore bad email addresses and do not raise email delivery errors.
74 | # Set this to true and configure the email server for immediate delivery to
75 | # raise delivery errors.
76 | # config.action_mailer.raise_delivery_errors = false
77 |
78 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
79 | # the I18n.default_locale when a translation cannot be found).
80 | config.i18n.fallbacks = true
81 |
82 | # Send deprecation notices to registered listeners.
83 | config.active_support.deprecation = :notify
84 |
85 | # Use default logging formatter so that PID and timestamp are not suppressed.
86 | config.log_formatter = ::Logger::Formatter.new
87 |
88 | # Use a different logger for distributed setups.
89 | # require 'syslog/logger'
90 | # config.logger = ActiveSupport::TaggedLogging.new(
91 | # Syslog::Logger.new 'app-name'
92 | # )
93 |
94 | if ENV['RAILS_LOG_TO_STDOUT'].present?
95 | logger = ActiveSupport::Logger.new(STDOUT)
96 | logger.formatter = config.log_formatter
97 | config.logger = ActiveSupport::TaggedLogging.new(logger)
98 | end
99 |
100 | # Do not dump schema after migrations.
101 | config.active_record.dump_schema_after_migration = false
102 | end
103 |
--------------------------------------------------------------------------------
/README-Localized/README-ja-jp.md:
--------------------------------------------------------------------------------
1 | ## Microsoft Graph Ruby on Rails Connect サンプル
2 |
3 | [](https://travis-ci.org/microsoftgraph/ruby-connect-rest-sample)
4 |
5 | Microsoft Graph を使用して、Ruby on Rails の Web アプリケーション内から Microsoft アカウントのユーザー リソースにアクセスします。このサンプルでは、Microsoft Graph エンドポイントへの REST の直接呼び出しを使ってユーザー リソースを操作します。ここでは、ユーザーとして電子メールを送信します。
6 |
7 | サンプルでは、OmniAuth ミドルウェアを使って、Azure AD v2.0 エンドポイントに対する認証を行います。Azure AD v2.0 エンドポイントにより、開発者はユーザーの職場または学校 (Azure Active Directory) アカウント、または Office 365、Outlook.com、および OneDrive の各アカウントなどの個人用 (Microsoft) アカウントの両方に対する認証を処理する単一のコード フローを記述することができます。
8 |
9 | サンプルでは、ユーザー エクスペリエンスのスタイル設定と書式設定に Office Fabric UI も使用します。
10 |
11 | 
12 |
13 | ## 前提条件
14 |
15 | このサンプルを使用するには、以下が必要です。
16 |
17 | - 開発サーバー上のサンプルを実行するための Ruby 2.4.2 (`.ruby-version` ファイルは、[rbenv](https://github.com/rbenv/rbenv#choosing-the-ruby-version)、[chruby](https://github.com/postmodern/chruby#auto-switching)、[rvm](https://rvm.io/workflow/projects) などの Ruby バージョン マネージャーに対して提供されます)。
18 | - Bundler 依存関係マネージャー。
19 | - [Microsoft アカウント](https://www.outlook.com/)または[ビジネス向けの Office 365 アカウント](https://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_Office365Account)
20 |
21 | ## アプリケーションを登録する
22 |
23 | Microsoft アプリ登録ポータルでアプリを登録します。これにより、認証するアプリの構成に使用するアプリ ID とパスワードが生成されます。
24 |
25 | 1. 個人用アカウント、あるいは職場または学校アカウントのいずれかを使用して、[Microsoft アプリ登録ポータル](https://apps.dev.microsoft.com/)にサインインします。
26 |
27 | 2. **[アプリの追加]** を選択します。
28 |
29 | 3. アプリの名前を入力して、**[作成]** を選択します。
30 |
31 | 登録ページが表示され、アプリのプロパティが一覧表示されます。
32 |
33 | 4. `Application Id` をコピーします。これは、アプリの一意識別子です。
34 |
35 | 5. **[アプリケーション シークレット]** で、**[新しいパスワードを生成する]** を選択します。**[新しいパスワードが生成されました]** ダイアログからアプリ シークレットをコピーします。
36 |
37 | アプリを構成するには、アプリケーション ID とアプリ シークレットを使用します。
38 |
39 | 6. **[プラットフォーム]** で、**[プラットフォームの追加]** > **[Web]** の順に選択します。
40 |
41 | 7. **[暗黙的フローを許可する]** のチェック ボックスが選択されていることを確認して、リダイレクト URI として「*http://localhost:3000/auth/microsoft_v2_auth/callback*」を入力します。
42 |
43 | **[暗黙的フローを許可する]** オプションにより、OpenID Connect ハイブリッド フローが有効になります。これにより、認証時にアプリはサインイン情報 (**id_token**) と成果物 (この場合は認証コード) の両方を受け取れるようになり、アプリはアクセス トークンを取得するときにこれらを使用できます。
44 |
45 | リダイレクト URI *http://localhost:3000/auth/microsoft_v2_auth/callback* は、認証要求が処理されたときに OmniAuth ミドルウェアで使用するように構成される値です。
46 |
47 | 8. **[保存]** を選択します。
48 |
49 | ## サンプルのビルドと実行
50 |
51 | 1. サンプルをダウンロードまたは複製し、任意のエディターで開きます。
52 | 1. [Bundler](http://bundler.io/) がない場合は、次のコマンドでインストールできます。
53 |
54 | ```
55 | gem install bundler
56 | ```
57 | 2. [config/environment.rb](config/environment.rb) ファイルで、次を実行します。
58 | 1. *ENTER_YOUR_CLIENT_ID* を登録済みのアプリケーションのアプリ ID と置き換えます。
59 | 2. *ENTER_YOUR_SECRET* を登録済みのアプリケーションのアプリ シークレットと置き換えます。
60 |
61 | 3. 次のコマンドを使って、Rails アプリケーションと依存関係をインストールします。
62 |
63 | ```
64 | bundle install
65 | ```
66 | 4. Rails アプリケーションを起動するには、次のコマンドを入力します。
67 |
68 | ```
69 | rails server --port=3000
70 | ```
71 | 5. Web ブラウザーで ```http://localhost:3000``` にアクセスします。
72 |
73 |
74 | ## 投稿 ##
75 |
76 | このサンプルに投稿する場合は、[CONTRIBUTING.MD](/CONTRIBUTING.md) を参照してください。
77 |
78 | このプロジェクトでは、[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) が採用されています。詳細については、「[規範に関する FAQ](https://opensource.microsoft.com/codeofconduct/faq/)」を参照してください。または、その他の質問やコメントがあれば、[opencode@microsoft.com](mailto:opencode@microsoft.com) までにお問い合わせください。
79 |
80 | ## 質問とコメント
81 |
82 | Microsoft Graph Ruby on Rails Connect のサンプルに関するフィードバックをお寄せください。質問や提案につきましては、このリポジトリの「[問題](https://github.com/microsoftgraph/ruby-connect-rest-sample/issues)」セクションで送信できます。
83 |
84 | お客様からのフィードバックを重視しています。[スタック オーバーフロー](http://stackoverflow.com/questions/tagged/office365+or+microsoftgraph)でご連絡いただけます。ご質問には [MicrosoftGraph] のタグを付けてください。
85 |
86 | ## 関連項目
87 |
88 | - [その他の Microsoft Graph Connect サンプル](https://github.com/MicrosoftGraph?utf8=%E2%9C%93&query=-Connect)
89 | - [Microsoft Graph のデベロッパー センター](http://graph.microsoft.io)
90 | - [Office UI Fabric](https://github.com/OfficeDev/Office-UI-Fabric)
91 |
92 | ## 著作権
93 | Copyright (c) 2016 Microsoft. All rights reserved.
94 |
--------------------------------------------------------------------------------
/app/controllers/pages_controller.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
3 | # See LICENSE in the project root for license information.
4 | ##
5 |
6 | # The controller manages the interaction of the pages with
7 | # the v2 authentication endpoint and the Microsoft Graph
8 | # To see how to get tokens for your app look at login and callback
9 | # To see how to send an email using the graph.microsoft.com
10 | # endpoint see send_mail
11 | # To see how to get rid of the tokens and finish the session
12 | # in your app, see disconnect
13 |
14 | class PagesController < ApplicationController
15 | skip_before_action :verify_authenticity_token
16 |
17 | # Specifies endpoint for connecting to the Microsoft Graph
18 | GRAPH_RESOURCE = 'https://graph.microsoft.com'.freeze
19 | SENDMAIL_ENDPOINT = '/v1.0/me/microsoft.graph.sendmail'.freeze
20 | CONTENT_TYPE =
21 | 'application/json;odata.metadata=minimal;odata.streaming=true'.freeze
22 |
23 | # Delegates the browser to the v2 authentication OmniAuth module
24 | # which takes the user to a sign-in page, if we don't have tokens already
25 | # This sample uses an open source OAuth 2.0 library that is compatible with
26 | # the Azure AD v2.0 endpoint.
27 | # Microsoft does not provide fixes or direct support for this library.
28 | # Refer to the library's repository to file issues or for other support.
29 | # For more information about auth libraries see: https://azure.microsoft.com/documentation/articles/active-directory-v2-libraries/
30 | # omniauth-oauth2 repo: https://github.com/intridea/omniauth-oauth2
31 |
32 | def login
33 | redirect_to '/auth/microsoft_v2_auth'
34 | end
35 |
36 | # If the user had to sign-in, the browser will redirect to this callback
37 | # with the authorization tokens attached
38 |
39 | def callback # rubocop:disable AbcSize
40 | # Access the authentication hash for omniauth
41 | # and extract the auth token, user name, and email
42 | data = request.env['omniauth.auth']
43 |
44 | @email = data[:extra][:raw_info][:userPrincipalName]
45 | @name = data[:extra][:raw_info][:displayName]
46 |
47 | # Associate token/user values to the session
48 | session[:access_token] = data['credentials']['token']
49 | session[:name] = @name
50 | session[:email] = @email
51 |
52 | # Debug logging
53 | logger.info "Name: #{@name}"
54 | logger.info "Email: #{@email}"
55 | logger.info "[callback] - Access token: #{session[:access_token]}"
56 | end
57 |
58 | def auth_hash
59 | request.env['omniauth.auth']
60 | end
61 |
62 | # Sends an authenticated request to the sendmail endpoint in
63 | # graph.microsoft.com
64 | # Stuff to consider:
65 | # - The email message is attached to the body of the request
66 | # - The access token must be appended to the authorization initheader
67 | # - Content type must be at least application/json
68 | # rubocop:disable Metrics/AbcSize
69 | def send_mail
70 | logger.debug "[send_mail] - Access token: #{session[:access_token]}"
71 |
72 | # Used in the template
73 | @name = session[:name]
74 | @email = params[:specified_email]
75 | @recipient = params[:specified_email]
76 | @mail_sent = false
77 |
78 | send_mail_endpoint = URI("#{GRAPH_RESOURCE}#{SENDMAIL_ENDPOINT}")
79 | content_type = CONTENT_TYPE
80 | http = Net::HTTP.new(send_mail_endpoint.host, send_mail_endpoint.port)
81 | http.use_ssl = true
82 |
83 | # If you want to use a sniffer tool, like Fiddler, to see the request
84 | # you might need to add this line to tell the engine not to verify the
85 | # certificate or you might see a "certificate verify failed" error
86 | # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
87 |
88 | email_body = File.read('app/assets/MailTemplate.html')
89 | email_body.sub! '{given_name}', @name
90 | email_subject = t('email_subject')
91 |
92 | logger.debug email_body
93 |
94 | email_message = "{
95 | Message: {
96 | Subject: '#{email_subject}',
97 | Body: {
98 | ContentType: 'HTML',
99 | Content: '#{email_body}'
100 | },
101 | ToRecipients: [
102 | {
103 | EmailAddress: {
104 | Address: '#{@recipient}'
105 | }
106 | }
107 | ]
108 | },
109 | SaveToSentItems: true
110 | }"
111 |
112 | response = http.post(
113 | SENDMAIL_ENDPOINT,
114 | email_message,
115 | 'Authorization' => "Bearer #{session[:access_token]}",
116 | 'Content-Type' => content_type
117 | )
118 |
119 | logger.debug "Code: #{response.code}"
120 | logger.debug "Message: #{response.message}"
121 |
122 | # The send mail endpoint returns a 202 - Accepted code on success
123 | if response.code == '202'
124 | @mail_sent = true
125 | else
126 | @mail_sent = false
127 | flash[:httpError] = "#{response.code} - #{response.message}"
128 | logger.debug response.body
129 | end
130 |
131 | render 'callback'
132 | end
133 | # rubocop:enable Metrics/AbcSize
134 |
135 | # Deletes the local session and redirects to root
136 | # the v2 endpoint doesn't currently support a logout endpoint
137 | # so we can't call it for a v2 logout flow
138 | def disconnect
139 | reset_session
140 | logger.info 'LOGOUT'
141 | redirect_to '/'
142 | end
143 | end
144 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## [ARCHIVED] Microsoft Graph Ruby on Rails Connect Sample
2 |
3 | ## IMPORTANT
4 |
5 | **This project is being archived and replaced with the [Build Ruby on Rails apps with Microsoft Graph](https://github.com/microsoftgraph/msgraph-training-rubyrailsapp). As part of the archival process, we're closing all open issues and pull requests.**
6 |
7 | **You can continue to use this sample "as-is", but it won't be maintained moving forward. We apologize for any inconvenience.**
8 |
9 | Use Microsoft Graph to access a user’s Microsoft account resources from within a Ruby on Rails web application. This sample uses REST calls directly to the Microsoft Graph endpoint to work with user resources--in this case, to send an email as the user.
10 |
11 | The sample uses OmniAuth middleware to authenticate against the Azure AD v2.0 endpoint. The Azure AD v2.0 endpoint enables developers to write a single code flow that handles authentication for both users' work or school (Azure Active Directory) or personal (Microsoft) accounts, including Office 365, Outlook.com, and OneDrive accounts.
12 |
13 | The sample also uses the Office Fabric UI for styling and formatting the user experience.
14 |
15 | 
16 |
17 | ## Prerequisites
18 |
19 | To use this sample, the following are required:
20 |
21 | - Ruby 2.4.2 to run the sample on a development server (a `.ruby-version` file is supplied for Ruby version managers like [rbenv](https://github.com/rbenv/rbenv#choosing-the-ruby-version), [chruby](https://github.com/postmodern/chruby#auto-switching), and [rvm](https://rvm.io/workflow/projects)).
22 | - Bundler dependency manager.
23 | - A [Microsoft account](https://www.outlook.com/) or an [Office 365 for business account](https://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_Office365Account)
24 |
25 | ## Register the application
26 |
27 | Register an app on the Microsoft App Registration Portal. This generates the app ID and password that you'll use to configure the app for authentication.
28 |
29 | 1. Sign into the [Microsoft App Registration Portal](https://apps.dev.microsoft.com/) using either your personal or work or school account.
30 |
31 | 2. Choose **Add an app**.
32 |
33 | 3. Enter a name for the app, and choose **Create**.
34 |
35 | The registration page displays, listing the properties of your app.
36 |
37 | 4. Copy the `Application Id`. This is the unique identifier for your app.
38 |
39 | 5. Under **Application Secrets**, choose **Generate New Password**. Copy the app secret from the **New password generated** dialog.
40 |
41 | You'll use the application ID and app secret to configure the app.
42 |
43 | 6. Under **Platforms**, choose **Add platform** > **Web**.
44 |
45 | 7. Make sure the **Allow Implicit Flow** check box is selected, and enter *http://localhost:3000/auth/microsoft_v2_auth/callback* as the Redirect URI.
46 |
47 | The **Allow Implicit Flow** option enables the OpenID Connect hybrid flow. During authentication, this enables the app to receive both sign-in info (the **id_token**) and artifacts (in this case, an authorization code) that the app uses to obtain an access token.
48 |
49 | The redirect URI *http://localhost:3000/auth/microsoft_v2_auth/callback* is the value that the OmniAuth middleware is configured to use once it has processed the authentication request.
50 |
51 | 8. Choose **Save**.
52 |
53 | ## Build and run the sample
54 |
55 | 1. Download or clone the sample and open it in the editor of your choice.
56 | 1. If you don't already have [bundler](http://bundler.io/), you can install it with the following command.
57 |
58 | ```
59 | gem install bundler
60 | ```
61 | 2. In the [config/environment.rb](config/environment.rb) file do the following.
62 | 1. Replace *ENTER_YOUR_CLIENT_ID* with the app ID of your registered application.
63 | 2. Replace *ENTER_YOUR_SECRET* with the app secret for your registered application.
64 |
65 | 3. Install the Rails application and dependencies with the following command.
66 |
67 | ```
68 | bundle install
69 | ```
70 | 4. To start the Rails application, type the following command.
71 |
72 | ```
73 | rails server --port=3000
74 | ```
75 | 5. Go to ```http://localhost:3000``` in your web browser.
76 |
77 |
78 | ## Contributing ##
79 |
80 | If you'd like to contribute to this sample, see [CONTRIBUTING.MD](/CONTRIBUTING.md).
81 |
82 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
83 |
84 | ## Questions and comments
85 |
86 | We'd love to get your feedback about the Microsoft Graph Ruby on Rails Connect sample. You can send your questions and suggestions to us in the [Issues](https://github.com/microsoftgraph/ruby-connect-rest-sample/issues) section of this repository.
87 |
88 | Your feedback is important to us. Connect with us on [Stack Overflow](http://stackoverflow.com/questions/tagged/office365+or+microsoftgraph). Tag your questions with [MicrosoftGraph].
89 |
90 | ## See also
91 |
92 | - [Other Microsoft Graph Connect samples](https://github.com/MicrosoftGraph?utf8=%E2%9C%93&query=-Connect)
93 | - [Microsoft Graph dev center](http://graph.microsoft.io)
94 | - [Office UI Fabric](https://github.com/OfficeDev/Office-UI-Fabric)
95 |
96 | ## Copyright
97 | Copyright (c) 2016 Microsoft. All rights reserved.
98 |
--------------------------------------------------------------------------------
/README-Localized/README-pt-br.md:
--------------------------------------------------------------------------------
1 | ## Exemplo de conexão com o Microsoft Graph Ruby on Rails
2 |
3 | [](https://travis-ci.org/microsoftgraph/ruby-connect-rest-sample)
4 |
5 | Utilize o Microsoft Graph para acessar os recursos de conta da Microsoft de um usuário a partir de um aplicativo Web do Ruby on Rails. Este exemplo utiliza chamadas REST diretamente para o ponto de extremidade do Microsoft Graph para trabalhar com os recursos do usuário. Neste caso, para enviar um email como o usuário.
6 |
7 | O exemplo usa o middleware de OmniAuth para autenticar no ponto de extremidade do Azure AD versão 2.0. O Azure AD versão 2.0 permite aos desenvolvedores gravar um único fluxo de código para tratar da autenticação de contas pessoais (Microsoft), corporativas ou de estudantes (Azure Active Directory), inclusive contas das plataformas Office 365, Outlook.com e OneDrive.
8 |
9 | O exemplo também usa a interface do usuário do Office Fabric para definir o estilo e a formatação da experiência do usuário.
10 |
11 | 
12 |
13 | ## Pré-requisitos
14 |
15 | Para utilizar este exemplo, são necessários:
16 |
17 | - Ruby 2.4.2 para executar o exemplo em um servidor de desenvolvimento (um arquivo `.ruby-version` é fornecido para gerenciadores de versão do Ruby, como [rbenv](https://github.com/rbenv/rbenv#choosing-the-ruby-version), [chruby](https://github.com/postmodern/chruby#auto-switching) e [rvm](https://rvm.io/workflow/projects)).
18 | - Gerenciador de dependências do Bundler.
19 | - Uma [conta da Microsoft](https://www.outlook.com/) ou uma [conta do Office 365 para empresas](https://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_Office365Account)
20 |
21 | ## Registrar o aplicativo
22 |
23 | Registre um aplicativo no Portal de Registro de Aplicativos da Microsoft. Isso gera a ID do aplicativo e a senha que você usará para configurar o aplicativo para autenticação.
24 |
25 | 1. Entre no [Portal de Registro de Aplicativos da Microsoft](https://apps.dev.microsoft.com/) usando sua conta pessoal ou uma conta corporativa ou de estudante.
26 |
27 | 2. Escolha **Adicionar um aplicativo**.
28 |
29 | 3. Insira um nome para o aplicativo e escolha **Criar**.
30 |
31 | A página de registro é exibida, listando as propriedades do seu aplicativo.
32 |
33 | 4. Copie o `Application Id`. Esse é o identificador exclusivo do aplicativo.
34 |
35 | 5. Em **Segredos do Aplicativo**, escolha **Gerar Nova Senha**. Copie o segredo do aplicativo da caixa de diálogo **Nova senha gerada**.
36 |
37 | Você usará a ID do aplicativo e o segredo do aplicativo para configurar o aplicativo.
38 |
39 | 6. Em **Plataformas**, escolha **Adicionar plataforma** > **Web**.
40 |
41 | 7. Não deixe de marcar a caixa de diálogo **Permitir Fluxo Implícito** e inserir *http://localhost:3000/auth/microsoft_v2_auth/callback* como o URI de Redirecionamento.
42 |
43 | A opção **Permitir Fluxo Implícito** habilita o fluxo híbrido do OpenID Connect. Durante a autenticação, isso permite que o aplicativo receba informações de entrada (o **id_token**) e artefatos (neste caso, um código de autorização) que o aplicativo usa para obter um token de acesso.
44 |
45 | O URI de redirecionamento *http://localhost:3000/auth/microsoft_v2_auth/callback* é o valor que o middleware OmniAuth está configurado para usar quando tiver processado a solicitação de autenticação.
46 |
47 | 8. Escolha **Salvar**.
48 |
49 | ## Criar e executar o exemplo
50 |
51 | 1. Baixe ou clone o exemplo e abra-o no editor de sua escolha.
52 | 1. Caso você ainda não tenha o [Bundler](http://bundler.io/), é possível instalá-lo com o comando seguinte.
53 |
54 | ```
55 | gem install bundler
56 | ```
57 | 2. No arquivo [config/environment.rb](config/environment.rb), faça o seguinte.
58 | 1. Substitua *ENTER_YOUR_CLIENT_ID* pela ID do aplicativo registrado.
59 | 2. Substitua *ENTER_YOUR_SECRET* pelo segredo do aplicativo registrado.
60 |
61 | 3. Instale o aplicativo Rails e as dependências com o seguinte comando.
62 |
63 | ```
64 | bundle install
65 | ```
66 | 4. Para iniciar o aplicativo Rails, digite o seguinte comando.
67 |
68 | ```
69 | rails server --port=3000
70 | ```
71 | 5. Acesse ```http://localhost:3000``` no navegador da Web.
72 |
73 |
74 | ## Colaboração ##
75 |
76 | Se quiser contribuir para esse exemplo, confira [CONTRIBUTING.MD](/CONTRIBUTING.md).
77 |
78 | Este projeto adotou o [Código de Conduta do Código Aberto da Microsoft](https://opensource.microsoft.com/codeofconduct/). Para saber mais, confira as [Perguntas frequentes do Código de Conduta](https://opensource.microsoft.com/codeofconduct/faq/) ou contate [opencode@microsoft.com](mailto:opencode@microsoft.com) se tiver outras dúvidas ou comentários.
79 |
80 | ## Perguntas e comentários
81 |
82 | Adoraríamos receber seus comentários sobre o projeto exemplo de Conexão do Microsoft Graph Ruby on Rails. Você pode nos enviar suas perguntas e sugestões por meio da seção [Issues](https://github.com/microsoftgraph/ruby-connect-rest-sample/issues) deste repositório.
83 |
84 | Seus comentários são importantes para nós. Junte-se a nós na página [Stack Overflow](http://stackoverflow.com/questions/tagged/office365+or+microsoftgraph). Marque suas perguntas com [MicrosoftGraph].
85 |
86 | ## Veja também
87 |
88 | - [Outros exemplos de conexão usando o Microsoft Graph](https://github.com/MicrosoftGraph?utf8=%E2%9C%93&query=-Connect)
89 | - [Centro de desenvolvimento do Microsoft Graph](http://graph.microsoft.io)
90 | - [Office UI Fabric](https://github.com/OfficeDev/Office-UI-Fabric)
91 |
92 | ## Copyright
93 | Copyright © 2016 Microsoft. Todos os direitos reservados.
94 |
--------------------------------------------------------------------------------
/README-Localized/README-ru-ru.md:
--------------------------------------------------------------------------------
1 | ## Пример Microsoft Graph Ruby on Rails Connect
2 |
3 | [](https://travis-ci.org/microsoftgraph/ruby-connect-rest-sample)
4 |
5 | Используйте Microsoft Graph для доступа к ресурсам учетной записи Майкрософт, принадлежащей пользователю, в веб-приложении Ruby on Rails. В этом примере показано, как с помощью вызовов REST непосредственно для конечной точки Microsoft Graph можно работать с ресурсами пользователя (в этом случае — чтобы отправить электронное сообщение от имени этого пользователя).
6 |
7 | В этом примере показано, как с помощью ПО промежуточного слоя OmniAuth можно обеспечить проверку подлинности с использованием конечной точки Azure AD 2.0. Конечная точка Azure AD версии 2.0 позволяет разработчикам создать один поток кода, обеспечивающий проверку подлинности как для рабочих или учебных (Azure Active Directory), так и для личных учетных записей Майкрософт, в том числе учетных записей Office 365, Outlook.com и OneDrive.
8 |
9 | В примере также используется Office Fabric для оформления и форматирования элементов пользовательского интерфейса.
10 |
11 | 
12 |
13 | ## Необходимые компоненты
14 |
15 | Чтобы воспользоваться этим приложением, необходимо следующее:
16 |
17 | - Ruby 2.4.2 для запуска приложения на сервере разработки (файл `.ruby-version` предоставлен для менеджеров версий Ruby, таких как [rbenv](https://github.com/rbenv/rbenv#choosing-the-ruby-version), [chruby](https://github.com/postmodern/chruby#auto-switching) и [rvm](https://rvm.io/workflow/projects));
18 | - диспетчер зависимостей Bundler;
19 | - [учетная запись Майкрософт](https://www.outlook.com/) или [учетная запись Office 365 для бизнеса](https://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_Office365Account).
20 |
21 | ## Регистрация приложения
22 |
23 | Зарегистрируйте приложение на портале регистрации приложений Майкрософт. При этом будут созданы пароль и идентификатор приложения, с помощью которых вы настроите приложение для проверки подлинности.
24 |
25 | 1. Войдите на [портал регистрации приложений Майкрософт](https://apps.dev.microsoft.com/) с помощью личной, рабочей или учебной учетной записи.
26 |
27 | 2. Нажмите кнопку **Добавить приложение**.
28 |
29 | 3. Введите имя приложения и нажмите **Создать**.
30 |
31 | Откроется страница регистрации со свойствами приложения.
32 |
33 | 4. Скопируйте `Application Id`. Это уникальный идентификатор приложения.
34 |
35 | 5. В разделе **Секреты приложения** нажмите кнопку **Создать новый пароль**. Скопируйте секрет приложения из диалогового окна **Новый пароль создан**.
36 |
37 | Идентификатор и секрет приложения используются для его настройки.
38 |
39 | 6. В разделе **Платформы** нажмите **Добавление платформы** > **Интернет**.
40 |
41 | 7. Установите флажок **Разрешить неявный поток** и введите URI перенаправления *http://localhost:3000/auth/microsoft_v2_auth/callback*.
42 |
43 | Параметр **Разрешить неявный поток** включает гибридный поток OpenID Connect. Благодаря этому при проверке подлинности приложение может получить данные для входа (**id_token**) и артефакты (в данном случае — код авторизации), с помощью которых оно может получить маркер доступа.
44 |
45 | URI перенаправления *http://localhost:3000/auth/microsoft_v2_auth/callback* — это значение, которое ПО промежуточного слоя OmniAuth использует после обработки запроса на проверку подлинности.
46 |
47 | 8. Нажмите кнопку **Сохранить**.
48 |
49 | ## Сборка и запуск примера
50 |
51 | 1. Скачайте или клонируйте пример и откройте его в удобном для себя редакторе.
52 | 1. Если у вас еще нет [bundler](http://bundler.io/), можете установить его с помощью приведенной ниже команды.
53 |
54 | ```
55 | gem install bundler
56 | ```
57 | 2. Выполните указанные ниже действия в файле [config/environment.rb](config/environment.rb).
58 | 1. Замените текст *ENTER_YOUR_CLIENT_ID* на идентификатор приложения для зарегистрированного приложения.
59 | 2. Замените текст *ENTER_YOUR_SECRET* на секрет для зарегистрированного приложения.
60 |
61 | 3. Установите приложение Rails и зависимости с помощью приведенной ниже команды.
62 |
63 | ```
64 | bundle install
65 | ```
66 | 4. Чтобы запустить приложение Rails, введите приведенную ниже команду.
67 |
68 | ```
69 | rails server --port=3000
70 | ```
71 | 5. Введите адрес ```http://localhost:3000``` в веб-браузере.
72 |
73 |
74 | ## Участие ##
75 |
76 | Если вы хотите добавить код в этот пример, просмотрите статью [CONTRIBUTING.MD](/CONTRIBUTING.md).
77 |
78 | Этот проект соответствует [правилам поведения Майкрософт, касающимся обращения с открытым кодом](https://opensource.microsoft.com/codeofconduct/). Читайте дополнительные сведения в [разделе вопросов и ответов по правилам поведения](https://opensource.microsoft.com/codeofconduct/faq/) или отправляйте новые вопросы и замечания по адресу [opencode@microsoft.com](mailto:opencode@microsoft.com).
79 |
80 | ## Вопросы и комментарии
81 |
82 | Мы будем рады получить от вас отзывы о примере Ruby on Rails Connect на базе Microsoft Graph. Вы можете отправлять нам вопросы и предложения на вкладке [Issues](https://github.com/microsoftgraph/ruby-connect-rest-sample/issues) (Вопросы) этого репозитория.
83 |
84 | Ваш отзыв важен для нас. Для связи с нами используйте сайт [Stack Overflow](http://stackoverflow.com/questions/tagged/office365+or+microsoftgraph). Помечайте свои вопросы тегом [MicrosoftGraph].
85 |
86 | ## См. также
87 |
88 | - [Другие примеры Microsoft Graph Connect](https://github.com/MicrosoftGraph?utf8=%E2%9C%93&query=-Connect)
89 | - [Центр разработки с помощью Microsoft Graph](http://graph.microsoft.io)
90 | - [Office UI Fabric](https://github.com/OfficeDev/Office-UI-Fabric)
91 |
92 | ## Авторское право
93 | (c) Корпорация Майкрософт (Microsoft Corporation), 2016. Все права защищены.
94 |
--------------------------------------------------------------------------------
/README-Localized/README-es-es.md:
--------------------------------------------------------------------------------
1 | ## Ejemplo de Microsoft Graph Ruby on Rails Connect
2 |
3 | [](https://travis-ci.org/microsoftgraph/ruby-connect-rest-sample)
4 |
5 | Utilizar Microsoft Graph para tener acceso a los recursos de la cuenta de Microsoft del usuario desde una aplicación web Ruby on Rails. Este ejemplo utiliza llamadas REST directamente al extremo de Microsoft Graph para trabajar con recursos del usuario: en este caso, para enviar un correo electrónico como el usuario.
6 |
7 | El ejemplo usa OmniAuth middleware para autenticarse en el extremo de Azure AD v2.0. El extremo de Azure AD v2.0 permite a los desarrolladores escribir un flujo de código simple que trata la autenticación tanto para las cuentas profesional o educativa (Azure Active Directory) como personales (Microsoft) de los usuarios, incluidas las cuentas de Office 365, Outlook.com y OneDrive.
8 |
9 | El ejemplo también usa la UI de Office Fabric para aplicar estilos y formatos a la experiencia del usuario.
10 |
11 | 
12 |
13 | ## Requisitos previos
14 |
15 | Para usar este ejemplo de código, se requiere lo siguiente:
16 |
17 | - Ruby 2.4.2, para ejecutar el ejemplo en un servidor de desarrollo (para los administradores de versiones de Ruby, como [rbenv](https://github.com/rbenv/rbenv#choosing-the-ruby-version), [chruby](https://github.com/postmodern/chruby#auto-switching) y [rvm](https://rvm.io/workflow/projects), se proporciona un archivo `.ruby-version`)
18 | - Administrador de dependencias Bundler
19 | - [Cuenta Microsoft](https://www.outlook.com/) o [cuenta de Office 365 para empresas](https://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_Office365Account)
20 |
21 | ## Registro de la aplicación
22 |
23 | Registre una aplicación en el Portal de registro de aplicaciones de Microsoft. Esta acción generará el ID y la contraseña de aplicación que usará para configurar la aplicación para la autenticación.
24 |
25 | 1. Inicie sesión en el [Portal de registro de aplicaciones de Microsoft](https://apps.dev.microsoft.com/) mediante su cuenta personal, profesional o educativa.
26 |
27 | 2. Seleccione **Agregar una aplicación**.
28 |
29 | 3. Escriba un nombre para la aplicación y seleccione **Crear**.
30 |
31 | Se mostrará la página de registro, en la que se indicarán las propiedades de la aplicación.
32 |
33 | 4. Copie el `Application Id`. Este es el identificador único de la aplicación.
34 |
35 | 5. En **Secretos de aplicación**, seleccione **Generar nueva contraseña**. Copie el secreto de aplicación del cuadro de diálogo **Nueva contraseña generada**.
36 |
37 | Deberá usar el ID y el secreto de aplicación para configurar la aplicación.
38 |
39 | 6. En **Plataformas**, elija **Agregar plataforma** > **Web**.
40 |
41 | 7. Asegúrese de que la casilla **Permitir flujo implícito** está seleccionada y escriba *http://localhost:3000/auth/microsoft_v2_auth/callback* como URI de redireccionamiento.
42 |
43 | La opción **Permitir flujo implícito**habilita el flujo híbrido de OpenID Connect. Durante la autenticación, esto permite que la aplicación reciba tanto la información de inicio de sesión (el **id_token**) como los artefactos (en este caso, un código de autorización) que la aplicación usa para obtener un token de acceso.
44 |
45 | El URI de redireccionamiento *http://localhost:3000/auth/microsoft_v2_auth/callback* es el valor con el que el middleware de OmniAuth se ha configurado para usar una vez que haya procesado la solicitud de autenticación.
46 |
47 | 8. Seleccione **Guardar**.
48 |
49 | ## Compilar y ejecutar el ejemplo
50 |
51 | 1. Descargue o clone el ejemplo y ábralo en el editor de su elección.
52 | 1. Si todavía no tiene [Bundler](http://bundler.io/), puede instalarlo con el siguiente comando.
53 |
54 | ```
55 | gem install bundler
56 | ```
57 | 2. En el archivo [config/environment.rb](config/environment.rb) realice lo siguiente:
58 | 1. Reemplace *ENTER_YOUR_CLIENT_ID* por el identificador de su aplicación registrada.
59 | 2. Reemplace *ENTER_YOUR_SECRET* por el secreto de su aplicación registrada.
60 |
61 | 3. Instale la aplicación Rails y las dependencias con el siguiente comando.
62 |
63 | ```
64 | bundle install
65 | ```
66 | 4. Para iniciar la aplicación Rails, escriba el siguiente comando.
67 |
68 | ```
69 | rails server --port=3000
70 | ```
71 | 5. Vaya a ```http://localhost:3000``` en el explorador web.
72 |
73 |
74 | ## Colaboradores ##
75 |
76 | Si le gustaría contribuir a este ejemplo, consulte [CONTRIBUTING.MD](/CONTRIBUTING.md).
77 |
78 | Este proyecto ha adoptado el [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) (Código de conducta de código abierto de Microsoft). Para obtener más información, consulte las [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) (Preguntas más frecuentes del código de conducta) o póngase en contacto con [opencode@microsoft.com](mailto:opencode@microsoft.com) con otras preguntas o comentarios.
79 |
80 | ## Preguntas y comentarios
81 |
82 | Nos encantaría recibir sus comentarios acerca del ejemplo de Microsoft Graph Ruby on Rails Connect. Puede enviarnos sus preguntas y sugerencias a través de la sección [Problemas](https://github.com/microsoftgraph/ruby-connect-rest-sample/issues) de este repositorio.
83 |
84 | Su opinión es importante para nosotros. Conecte con nosotros en [Desbordamiento de pila](http://stackoverflow.com/questions/tagged/office365+or+microsoftgraph). Etiquete sus preguntas con [MicrosoftGraph].
85 |
86 | ## Ver también
87 |
88 | - [Otros ejemplos de Microsoft Graph Connect](https://github.com/MicrosoftGraph?utf8=%E2%9C%93&query=-Connect)
89 | - [Centro de desarrollo de Microsoft Graph](http://graph.microsoft.io)
90 | - [Office UI Fabric](https://github.com/OfficeDev/Office-UI-Fabric)
91 |
92 | ## Copyright
93 | Copyright (c) 2016 Microsoft. Todos los derechos reservados.
94 |
--------------------------------------------------------------------------------
/README-Localized/README-fr-fr.md:
--------------------------------------------------------------------------------
1 | ## Exemple de connexion avec Microsoft Graph pour Ruby on Rails
2 |
3 | [](https://travis-ci.org/microsoftgraph/ruby-connect-rest-sample)
4 |
5 | Microsoft Graph permet d’accéder aux ressources de compte Microsoft d’un utilisateur à partir d’une application web Ruby on Rails. Cet exemple utilise les appels REST directement vers le point de terminaison Microsoft Graph pour travailler avec les ressources des utilisateurs, dans ce cas pour envoyer un e-mail en tant qu’utilisateur.
6 |
7 | L’exemple utilise l’intergiciel OmniAuth pour l’authentification auprès du point de terminaison Azure AD v2.0. Le point de terminaison Azure AD v2.0 permet aux développeurs d’écrire un flux de code unique qui gère l’authentification des comptes professionnels ou scolaires (Azure Active Directory) et personnels (Microsoft), y compris des comptes Office 365, Outlook.com et OneDrive.
8 |
9 | L’exemple utilise également la structure d’interface utilisateur Office pour l’application d’un style à l’expérience utilisateur et sa mise en forme.
10 |
11 | 
12 |
13 | ## Conditions préalables
14 |
15 | Pour utiliser cet exemple, les éléments suivants sont requis :
16 |
17 | - Ruby 2.4.2 pour exécuter l’exemple sur un serveur de développement (un fichier `.ruby-version` est fourni pour les gestionnaires de version Ruby comme [rbenv](https://github.com/rbenv/rbenv#choosing-the-ruby-version), [chruby](https://github.com/postmodern/chruby#auto-switching) et [rvm](https://rvm.io/workflow/projects)).
18 | - Gestionnaire de dépendances Bundler.
19 | - [Compte Microsoft](https://www.outlook.com/) ou [compte Office 365 pour les entreprises](https://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_Office365Account)
20 |
21 | ## Inscription de l’application
22 |
23 | Inscrivez une application sur le portail d’inscription des applications Microsoft. L’inscription génère l’ID et le mot de passe de l’application que vous utiliserez pour configurer l’application pour l’authentification.
24 |
25 | 1. Connectez-vous au [portail d’inscription des applications Microsoft](https://apps.dev.microsoft.com/) en utilisant votre compte personnel, professionnel ou scolaire.
26 |
27 | 2. Choisissez **Ajouter une application**.
28 |
29 | 3. Entrez un nom pour l’application, puis choisissez **Créer**.
30 |
31 | La page d’inscription s’affiche, répertoriant les propriétés de votre application.
32 |
33 | 4. Copie l’`Application Id`. Il s’agit de l’identificateur unique de votre application.
34 |
35 | 5. Sous **Secrets de l'application**, choisissez **Générer un nouveau mot de passe**. Copiez la question secrète de l’application à partir de la boîte de dialogue **Nouveau mot de passe créé**.
36 |
37 | Vous utiliserez l’ID de l’application et la question secrète de l’application pour configurer l’application.
38 |
39 | 6. Sous **Plateformes**, choisissez **Ajouter une plateforme** > **Web**.
40 |
41 | 7. Assurez-vous que la case **Autoriser le flux implicite** est cochée, puis entrez *http://localhost:3000/auth/microsoft_v2_auth/callback* comme URI de redirection.
42 |
43 | L’option **Autoriser le flux implicite** active le flux hybride OpenID Connect. Lors de l’authentification, cela permet à l’application de recevoir les informations de connexion (**id_token**) et les artefacts (dans ce cas, un code d’autorisation) qui servent à obtenir un jeton d’accès.
44 |
45 | L’URI de redirection *http://localhost:3000/auth/microsoft_v2_auth/callback* est la valeur que doit utiliser l’intergiciel OmniAuth une fois qu’il a traité la demande d’authentification.
46 |
47 | 8. Cliquez sur **Enregistrer**.
48 |
49 | ## Création et exécution de l’exemple
50 |
51 | 1. Téléchargez ou clonez l’exemple et ouvrez-le dans l’éditeur de votre choix.
52 | 1. Si vous n’avez pas encore [Bundler](http://bundler.io/) sur votre ordinateur, vous pouvez l’installer avec la commande suivante.
53 |
54 | ```
55 | gem install bundler
56 | ```
57 | 2. Dans le fichier [config/environment.rb](config/environment.rb), suivez les étapes ci-dessous :
58 | 1. Remplacez *ENTER_YOUR_CLIENT_ID* par l’ID de votre application inscrite.
59 | 2. Remplacez *ENTER_YOUR_SECRET* par la question secrète de votre application inscrite.
60 |
61 | 3. Installez l’application Rails et les dépendances avec la commande suivante.
62 |
63 | ```
64 | bundle install
65 | ```
66 | 4. Pour démarrer l’application Rails, entrez la commande suivante.
67 |
68 | ```
69 | rails server --port=3000
70 | ```
71 | 5. Accédez à ```http://localhost:3000``` dans votre navigateur web.
72 |
73 |
74 | ## Contribution ##
75 |
76 | Si vous souhaitez contribuer à cet exemple, voir [CONTRIBUTING.MD](/CONTRIBUTING.md).
77 |
78 | Ce projet a adopté le [code de conduite Microsoft Open Source](https://opensource.microsoft.com/codeofconduct/). Pour plus d’informations, reportez-vous à la [FAQ relative au code de conduite](https://opensource.microsoft.com/codeofconduct/faq/) ou contactez [opencode@microsoft.com](mailto:opencode@microsoft.com) pour toute question ou tout commentaire.
79 |
80 | ## Questions et commentaires
81 |
82 | Nous serions ravis de connaître votre opinion sur l’exemple de connexion Microsoft Graph pour Ruby on Rails. Vous pouvez nous faire part de vos questions et suggestions dans la rubrique [Problèmes](https://github.com/microsoftgraph/ruby-connect-rest-sample/issues) de ce référentiel.
83 |
84 | Votre avis compte beaucoup pour nous. Communiquez avec nous sur [Stack Overflow](http://stackoverflow.com/questions/tagged/office365+or+microsoftgraph). Posez vos questions avec la balise [MicrosoftGraph].
85 |
86 | ## Voir aussi
87 |
88 | - [Autres exemples de connexion avec Microsoft Graph](https://github.com/MicrosoftGraph?utf8=%E2%9C%93&query=-Connect)
89 | - [Centre de développement Microsoft Graph](http://graph.microsoft.io)
90 | - [Structure de l’interface utilisateur Office](https://github.com/OfficeDev/Office-UI-Fabric)
91 |
92 | ## Copyright
93 | Copyright (c) 2016 Microsoft. Tous droits réservés.
94 |
--------------------------------------------------------------------------------
/README-Localized/README-de-de.md:
--------------------------------------------------------------------------------
1 | ## Microsoft Graph Ruby on Rails Connect-Beispiel
2 |
3 | [](https://travis-ci.org/microsoftgraph/ruby-connect-rest-sample)
4 |
5 | Verwenden Sie Microsoft Graph, um auf die Microsoft-Kontoressourcen eines Benutzers über die Webanwendung von Ruby on Rails zuzugreifen. In diesem Beispiel werden direkte REST-Aufrufe des Microsoft Graph-Endpunkts zur Verwendung der Benutzerressourcen verwendet – in diesem Fall, um eine Mail als dieser Benutzer zu senden.
6 |
7 | Im Beispiel wird die OmniAuth-Middleware zur Authentifizierung beim Azure AD v2.0-Endpunkt verwendet. Der Azure AD v2.0-Endpunkt ermöglicht Entwicklern, einen einzelnen Codefluss zu schreiben, der die Authentifizierung sowohl für Geschäfts- oder Schulkonten von Benutzern (Azure Active Directory) als auch für persönliche Konten (Microsoft) verarbeitet, einschließlich Office 365-, Outlook.com- und OneDrive-Konten.
8 |
9 | Im Beispiel wird auch die Office-Fabric-UI zum Entwerfen und Formatieren der Benutzeroberfläche verwendet.
10 |
11 | 
12 |
13 | ## Voraussetzungen
14 |
15 | Um dieses Beispiel verwenden zu können, ist Folgendes erforderlich:
16 |
17 | - Ruby 2.4.2 zum Ausführen des Beispiels auf einem Entwicklungsserver (eine `.ruby-version`-Datei ist für Manager von Ruby-Versionen wie [rbenv](https://github.com/rbenv/rbenv#choosing-the-ruby-version), [chruby](https://github.com/postmodern/chruby#auto-switching), und [rvm](https://rvm.io/workflow/projects) angegeben).
18 | - Bundler Dependency Manager.
19 | - Ein [Microsoft-Konto](https://www.outlook.com/) oder ein [Office 365 for Business](https://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_Office365Account)-Konto.
20 |
21 | ## Registrieren der App
22 |
23 | Registrieren Sie eine App im Microsoft App-Registrierungsportal. Dadurch werden die ID und das Kennwort der App generiert, mit der bzw. dem Sie die App für die Authentifizierung konfigurieren.
24 |
25 | 1. Melden Sie sich beim [Microsoft-App-Registrierungsportal](https://apps.dev.microsoft.com/) entweder mit Ihrem persönlichen oder geschäftlichen Konto oder mit Ihrem Schulkonto an.
26 |
27 | 2. Klicken Sie auf **App hinzufügen**.
28 |
29 | 3. Geben Sie einen Namen für die App ein, und wählen Sie **Erstellen**.
30 |
31 | Die Registrierungsseite wird angezeigt, und die Eigenschaften der App werden aufgeführt.
32 |
33 | 4. Kopieren Sie die `Application Id`. Dies ist der eindeutige Bezeichner für Ihre App.
34 |
35 | 5. Wählen Sie unter **Anwendungsgeheimnisse** die Option **Neues Kennwort generieren** aus. Kopieren Sie das Anwendungsgeheimnis aus dem Dialogfeld **Neues Kennwort wurde generiert**.
36 |
37 | Sie werden die ID und das Geheimnis der Anwendung verwenden, um die App zu konfigurieren.
38 |
39 | 6. Wählen Sie unter **Plattformen** die Option **Plattform hinzufügen** > ** Web** aus.
40 |
41 | 7. Stellen Sie sicher, dass das Kontrollkästchen **Impliziten Fluss zulassen** aktiviert ist, und geben Sie *http://localhost:3000/auth/microsoft_v2_auth/callback* als Umleitungs-URI ein.
42 |
43 | Die Option **Impliziten Fluss zulassen** ermöglicht den OpenID Connect-Hybridfluss. Während der Authentifizierung ermöglicht dies der App, sowohl Anmeldeinformationen (das **id_token**) als auch Artefakte (in diesem Fall ein Autorisierungscode) abzurufen, den die App zum Abrufen eines Zugriffstokens verwendet.
44 |
45 | Der Umleitungs-URI *Http://localhost:3000/autorisierende/microsoft_v2_auth/Rückruf* ist der Wert, den die OmniAuth Middleware entsprechend der Konfiguration verwendet, wenn sie die Authentifizierungsanforderung verarbeitet hat.
46 |
47 | 8. Wählen Sie **Speichern** aus.
48 |
49 | ## Erstellen und Ausführen des Beispiels
50 |
51 | 1. Laden Sie das Beispiel herunter, oder klonen Sie es, und öffnen Sie es dann im gewünschten Editor.
52 | 1. Wenn Sie über keinen [Bundler](http://bundler.io/) verfügen, können Sie ihn mithilfe des folgenden Befehls installieren.
53 |
54 | ```
55 | gem install bundler
56 | ```
57 | 2. Nehmen Sie in der Datei [config/environment.rb](config/environment.rb) die folgende Aktion vor.
58 | 1. Ersetzen Sie *ENTER_YOUR_CLIENT_ID* durch die App-ID Ihrer registrierten Anwendung.
59 | 2. Ersetzen Sie *ENTER_YOUR_SECRET* durch das App-Geheimnis Ihrer registrierten Anwendung.
60 |
61 | 3. Installieren Sie die Rails-Anwendung und -Abhängigkeiten mit dem folgenden Befehl.
62 |
63 | ```
64 | bundle install
65 | ```
66 | 4. Geben Sie zum Starten der Rails-Anwendung den folgenden Befehl ein.
67 |
68 | ```
69 | rails server --port=3000
70 | ```
71 | 5. Navigieren Sie im Webbrowser zu ```http://localhost:3000```.
72 |
73 |
74 | ## Mitwirkung ##
75 |
76 | Wenn Sie einen Beitrag zu diesem Beispiel leisten möchten, finden Sie unter [CONTRIBUTING.MD](/CONTRIBUTING.md) weitere Informationen.
77 |
78 | In diesem Projekt wurden die [Microsoft Open Source-Verhaltensregeln](https://opensource.microsoft.com/codeofconduct/) übernommen. Weitere Informationen finden Sie unter [Häufig gestellte Fragen zu Verhaltensregeln](https://opensource.microsoft.com/codeofconduct/faq/), oder richten Sie Ihre Fragen oder Kommentare an [opencode@microsoft.com](mailto:opencode@microsoft.com).
79 |
80 | ## Fragen und Kommentare
81 |
82 | Wir freuen uns, Ihr Feedback zum Microsoft Graph Ruby on Rails Connect-Beispiel zu erhalten. Sie können uns Ihre Fragen und Vorschläge über den Abschnitt [Probleme](https://github.com/microsoftgraph/ruby-connect-rest-sample/issues) dieses Repositorys senden.
83 |
84 | Ihr Feedback ist uns wichtig. Nehmen Sie unter [Stack Overflow](http://stackoverflow.com/questions/tagged/office365+or+microsoftgraph) Kontakt mit uns auf. Taggen Sie Ihre Fragen mit [MicrosoftGraph].
85 |
86 | ## Siehe auch
87 |
88 | - [Weitere Microsoft Graph Connect-Beispiele](https://github.com/MicrosoftGraph?utf8=%E2%9C%93&query=-Connect)
89 | - [Microsoft Graph Dev Center](http://graph.microsoft.io)
90 | - [Office UI Fabric](https://github.com/OfficeDev/Office-UI-Fabric)
91 |
92 | ## Copyright
93 | Copyright (c) 2016 Microsoft. Alle Rechte vorbehalten.
94 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GIT
2 | remote: https://github.com/cbales/omniauth-microsoft_graph
3 | revision: f3a96241baf40b9019097b922690da9359933e41
4 | specs:
5 | omniauth-microsoft_v2_auth (0.1.0)
6 | omniauth-oauth2
7 |
8 | GIT
9 | remote: https://github.com/sparklemotion/sqlite3-ruby
10 | revision: eb16642386c8cbbab52998f142a8a25bd8124b13
11 | specs:
12 | sqlite3 (1.3.13.20180326210955)
13 |
14 | GEM
15 | remote: https://rubygems.org/
16 | specs:
17 | actioncable (5.2.0)
18 | actionpack (= 5.2.0)
19 | nio4r (~> 2.0)
20 | websocket-driver (>= 0.6.1)
21 | actionmailer (5.2.0)
22 | actionpack (= 5.2.0)
23 | actionview (= 5.2.0)
24 | activejob (= 5.2.0)
25 | mail (~> 2.5, >= 2.5.4)
26 | rails-dom-testing (~> 2.0)
27 | actionpack (5.2.0)
28 | actionview (= 5.2.0)
29 | activesupport (= 5.2.0)
30 | rack (~> 2.0)
31 | rack-test (>= 0.6.3)
32 | rails-dom-testing (~> 2.0)
33 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
34 | actionview (5.2.0)
35 | activesupport (= 5.2.0)
36 | builder (~> 3.1)
37 | erubi (~> 1.4)
38 | rails-dom-testing (~> 2.0)
39 | rails-html-sanitizer (~> 1.0, >= 1.0.3)
40 | activejob (5.2.0)
41 | activesupport (= 5.2.0)
42 | globalid (>= 0.3.6)
43 | activemodel (5.2.0)
44 | activesupport (= 5.2.0)
45 | activerecord (5.2.0)
46 | activemodel (= 5.2.0)
47 | activesupport (= 5.2.0)
48 | arel (>= 9.0)
49 | activestorage (5.2.0)
50 | actionpack (= 5.2.0)
51 | activerecord (= 5.2.0)
52 | marcel (~> 0.3.1)
53 | activesupport (5.2.0)
54 | concurrent-ruby (~> 1.0, >= 1.0.2)
55 | i18n (>= 0.7, < 2)
56 | minitest (~> 5.1)
57 | tzinfo (~> 1.1)
58 | arel (9.0.0)
59 | ast (2.4.0)
60 | bindex (0.5.0)
61 | builder (3.2.3)
62 | byebug (10.0.2)
63 | concurrent-ruby (1.0.5)
64 | crass (1.0.4)
65 | erubi (1.7.1)
66 | faraday (0.12.2)
67 | multipart-post (>= 1.2, < 3)
68 | ffi (1.9.25)
69 | ffi (1.9.25-x64-mingw32)
70 | ffi (1.9.25-x86-mingw32)
71 | globalid (0.4.1)
72 | activesupport (>= 4.2.0)
73 | hashie (3.5.7)
74 | i18n (1.0.1)
75 | concurrent-ruby (~> 1.0)
76 | jaro_winkler (1.4.0)
77 | jwt (1.5.6)
78 | listen (3.1.5)
79 | rb-fsevent (~> 0.9, >= 0.9.4)
80 | rb-inotify (~> 0.9, >= 0.9.7)
81 | ruby_dep (~> 1.2)
82 | loofah (2.2.2)
83 | crass (~> 1.0.2)
84 | nokogiri (>= 1.5.9)
85 | mail (2.7.0)
86 | mini_mime (>= 0.1.1)
87 | marcel (0.3.2)
88 | mimemagic (~> 0.3.2)
89 | method_source (0.9.0)
90 | mimemagic (0.3.2)
91 | mini_mime (1.0.0)
92 | mini_portile2 (2.3.0)
93 | minitest (5.11.3)
94 | multi_json (1.13.1)
95 | multi_xml (0.6.0)
96 | multipart-post (2.0.0)
97 | nio4r (2.3.1)
98 | nokogiri (1.8.2)
99 | mini_portile2 (~> 2.3.0)
100 | nokogiri (1.8.2-x64-mingw32)
101 | mini_portile2 (~> 2.3.0)
102 | nokogiri (1.8.2-x86-mingw32)
103 | mini_portile2 (~> 2.3.0)
104 | oauth2 (1.4.0)
105 | faraday (>= 0.8, < 0.13)
106 | jwt (~> 1.0)
107 | multi_json (~> 1.3)
108 | multi_xml (~> 0.5)
109 | rack (>= 1.2, < 3)
110 | omniauth (1.8.1)
111 | hashie (>= 3.4.6, < 3.6.0)
112 | rack (>= 1.6.2, < 3)
113 | omniauth-oauth2 (1.5.0)
114 | oauth2 (~> 1.1)
115 | omniauth (~> 1.2)
116 | parallel (1.12.1)
117 | parser (2.5.1.0)
118 | ast (~> 2.4.0)
119 | powerpack (0.1.1)
120 | rack (2.0.5)
121 | rack-test (1.0.0)
122 | rack (>= 1.0, < 3)
123 | rails (5.2.0)
124 | actioncable (= 5.2.0)
125 | actionmailer (= 5.2.0)
126 | actionpack (= 5.2.0)
127 | actionview (= 5.2.0)
128 | activejob (= 5.2.0)
129 | activemodel (= 5.2.0)
130 | activerecord (= 5.2.0)
131 | activestorage (= 5.2.0)
132 | activesupport (= 5.2.0)
133 | bundler (>= 1.3.0)
134 | railties (= 5.2.0)
135 | sprockets-rails (>= 2.0.0)
136 | rails-dom-testing (2.0.3)
137 | activesupport (>= 4.2.0)
138 | nokogiri (>= 1.6)
139 | rails-html-sanitizer (1.0.4)
140 | loofah (~> 2.2, >= 2.2.2)
141 | railties (5.2.0)
142 | actionpack (= 5.2.0)
143 | activesupport (= 5.2.0)
144 | method_source
145 | rake (>= 0.8.7)
146 | thor (>= 0.18.1, < 2.0)
147 | rainbow (3.0.0)
148 | rake (12.3.1)
149 | rb-fsevent (0.10.3)
150 | rb-inotify (0.9.10)
151 | ffi (>= 0.5.0, < 2)
152 | rdoc (6.0.4)
153 | rubocop (0.57.0)
154 | jaro_winkler (~> 1.4.0)
155 | parallel (~> 1.10)
156 | parser (>= 2.5)
157 | powerpack (~> 0.1)
158 | rainbow (>= 2.2.2, < 4.0)
159 | ruby-progressbar (~> 1.7)
160 | unicode-display_width (~> 1.0, >= 1.0.1)
161 | ruby-progressbar (1.9.0)
162 | ruby_dep (1.5.0)
163 | sdoc (1.0.0)
164 | rdoc (>= 5.0)
165 | spring (2.0.2)
166 | activesupport (>= 4.2)
167 | spring-watcher-listen (2.0.1)
168 | listen (>= 2.7, < 4.0)
169 | spring (>= 1.2, < 3.0)
170 | sprockets (3.7.1)
171 | concurrent-ruby (~> 1.0)
172 | rack (> 1, < 3)
173 | sprockets-rails (3.2.1)
174 | actionpack (>= 4.0)
175 | activesupport (>= 4.0)
176 | sprockets (>= 3.0.0)
177 | thor (0.20.0)
178 | thread_safe (0.3.6)
179 | turbolinks (5.0.0)
180 | turbolinks-source (~> 5)
181 | turbolinks-source (5.1.0)
182 | tzinfo (1.2.5)
183 | thread_safe (~> 0.1)
184 | tzinfo-data (1.2018.5)
185 | tzinfo (>= 1.0.0)
186 | unicode-display_width (1.4.0)
187 | wdm (0.1.1)
188 | web-console (3.6.2)
189 | actionview (>= 5.0)
190 | activemodel (>= 5.0)
191 | bindex (>= 0.4.0)
192 | railties (>= 5.0)
193 | websocket-driver (0.7.0)
194 | websocket-extensions (>= 0.1.0)
195 | websocket-extensions (0.1.3)
196 |
197 | PLATFORMS
198 | ruby
199 | x64-mingw32
200 | x86-mingw32
201 |
202 | DEPENDENCIES
203 | byebug
204 | listen (>= 3.0.5, < 3.2)
205 | omniauth-microsoft_v2_auth!
206 | rack (= 2.0.5)
207 | rails (= 5.2.0)
208 | rubocop (= 0.57.0)
209 | sdoc
210 | spring
211 | spring-watcher-listen (~> 2.0.0)
212 | sqlite3!
213 | turbolinks (= 5)
214 | tzinfo-data
215 | wdm (>= 0.1.0)
216 | web-console (>= 3.3.0)
217 |
218 | RUBY VERSION
219 | ruby 2.5.1p57
220 |
221 | BUNDLED WITH
222 | 1.16.2
223 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contribute to this documentation
2 |
3 | Thank you for your interest in our documentation!
4 |
5 | * [Ways to contribute](#ways-to-contribute)
6 | * [Contribute using GitHub](#contribute-using-github)
7 | * [Contribute using Git](#contribute-using-git)
8 | * [How to use Markdown to format your topic](#how-to-use-markdown-to-format-your-topic)
9 | * [FAQ](#faq)
10 | * [More resources](#more-resources)
11 |
12 | ## Ways to contribute
13 |
14 | Here are some ways you can contribute to this documentation:
15 |
16 | * To make small changes to an article, [Contribute using GitHub](#contribute-using-github).
17 | * To make large changes, or changes that involve code, [Contribute using Git](#contribute-using-git).
18 | * Report documentation bugs via GitHub Issues
19 | * Request new documentation at the [Office Developer Platform UserVoice](http://officespdev.uservoice.com) site.
20 |
21 | ## Contribute using GitHub
22 |
23 | Use GitHub to contribute to this documentation without having to clone the repo to your desktop. This is the easiest way to create a pull request in this repository. Use this method to make a minor change that doesn't involve code changes.
24 |
25 | **Note** Using this method allows you to contribute to one article at a time.
26 |
27 | ### To Contribute using GitHub
28 |
29 | 1. Find the article you want to contribute to on GitHub.
30 |
31 | If the article is in MSDN, choose the **suggest and submit changes** link in the **Contribute to this content** section and you'll be taken to the same article on GitHub.
32 | 2. Once you are on the article in GitHub, sign in to GitHub (get a free account [Join GitHub](https://github.com/join).
33 | 3. Choose the **pencil icon** (edit the file in your fork of this project) and make your changes in the **<>Edit file** window.
34 | 4. Scroll to the bottom and enter a description.
35 | 5. Choose **Propose file change**>**Create pull request**.
36 |
37 | You now have successfully submitted a pull request. Pull requests are typically reviewed within 10 business days.
38 |
39 |
40 | ## Contribute using Git
41 |
42 | Use Git to contribute substantive changes, such as:
43 |
44 | * Contributing code.
45 | * Contributing changes that affect meaning.
46 | * Contributing large changes to text.
47 | * Adding new topics.
48 |
49 | ### To Contribute using Git
50 |
51 | 1. If you don't have a GitHub account, set one up at [GitHub](https://github.com/join).
52 | 2. After you have an account, install Git on your computer. Follow the steps in [Setting up Git Tutorial](https://help.github.com/articles/set-up-git/).
53 | 3. To submit a pull request using Git, follow the steps in [Use GitHub, Git, and this repository](#use-github-git-and-this-repository).
54 | 4. You will be asked to sign the Contributor's License Agreement if you are:
55 |
56 | * A member of the Microsoft Open Technologies group.
57 | * A contributors who doesn't work for Microsoft.
58 |
59 | As a community member, you must sign the Contribution License Agreement (CLA) before you can contribute large submissions to a project. You only need to complete and submit the documentation once. Carefully review the document. You may be required to have your employer sign the document.
60 |
61 | Signing the CLA does not grant you rights to commit to the main repository, but it does mean that the Office Developer and Office Developer Content Publishing teams will be able to review and approve your contributions. You will be credited for your submissions.
62 |
63 | Pull requests are typically reviewed within 10 business days.
64 |
65 | ## Use GitHub, Git, and this repository
66 |
67 | **Note:** Most of the information in this section can be found in [GitHub Help] articles. If you're familiar with Git and GitHub, skip to the **Contribute and edit content** section for the specifics of the code/content flow of this repository.
68 |
69 | ### To set up your fork of the repository
70 |
71 | 1. Set up a GitHub account so you can contribute to this project. If you haven't done this, go to [GitHub](https://github.com/join) and do it now.
72 | 2. Install Git on your computer. Follow the steps in the [Setting up Git Tutorial] [Set Up Git].
73 | 3. Create your own fork of this repository. To do this, at the top of the page, choose the **Fork** button.
74 | 4. Copy your fork to your computer. To do this, open Git Bash. At the command prompt enter:
75 |
76 | git clone https://github.com//.git
77 |
78 | Next, create a reference to the root repository by entering these commands:
79 |
80 | cd
81 | git remote add upstream https://github.com/microsoftgraph/.git
82 | git fetch upstream
83 |
84 | Congratulations! You've now set up your repository. You won't need to repeat these steps again.
85 |
86 | ### Contribute and edit content
87 |
88 | To make the contribution process as seamless as possible, follow these steps.
89 |
90 | #### To contribute and edit content
91 |
92 | 1. Create a new branch.
93 | 2. Add new content or edit existing content.
94 | 3. Submit a pull request to the main repository.
95 | 4. Delete the branch.
96 |
97 | **Important** Limit each branch to a single concept/article to streamline the work flow and reduce the chance of merge conflicts. Content appropriate for a new branch includes:
98 |
99 | * A new article.
100 | * Spelling and grammar edits.
101 | * Applying a single formatting change across a large set of articles (for example, applying a new copyright footer).
102 |
103 | #### To create a new branch
104 |
105 | 1. Open Git Bash.
106 | 2. At the Git Bash command prompt, type `git pull upstream master:`. This creates a new branch locally that is copied from the latest MicrosoftGraph master branch.
107 | 3. At the Git Bash command prompt, type `git push origin `. This alerts GitHub to the new branch. You should now see the new branch in your fork of the repository on GitHub.
108 | 4. At the Git Bash command prompt, type `git checkout ` to switch to your new branch.
109 |
110 | #### Add new content or edit existing content
111 |
112 | You navigate to the repository on your computer by using File Explorer. The repository files are in `C:\Users\\`.
113 |
114 | To edit files, open them in an editor of your choice and modify them. To create a new file, use the editor of your choice and save the new file in the appropriate location in your local copy of the repository. While working, save your work frequently.
115 |
116 | The files in `C:\Users\\` are a working copy of the new branch that you created in your local repository. Changing anything in this folder doesn't affect the local repository until you commit a change. To commit a change to the local repository, type the following commands in GitBash:
117 |
118 | git add .
119 | git commit -v -a -m ""
120 |
121 | The `add` command adds your changes to a staging area in preparation for committing them to the repository. The period after the `add` command specifies that you want to stage all of the files that you added or modified, checking subfolders recursively. (If you don't want to commit all of the changes, you can add specific files. You can also undo a commit. For help, type `git add -help` or `git status`.)
122 |
123 | The `commit` command applies the staged changes to the repository. The switch `-m` means you are providing the commit comment in the command line. The -v and -a switches can be omitted. The -v switch is for verbose output from the command, and -a does what you already did with the add command.
124 |
125 | You can commit multiple times while you are doing your work, or you can commit once when you're done.
126 |
127 | #### Submit a pull request to the main repository
128 |
129 | When you're finished with your work and are ready to have it merged into the main repository, follow these steps.
130 |
131 | #### To submit a pull request to the main repository
132 |
133 | 1. In the Git Bash command prompt, type `git push origin `. In your local repository, `origin` refers to your GitHub repository that you cloned the local repository from. This command pushes the current state of your new branch, including all commits made in the previous steps, to your GitHub fork.
134 | 2. On the GitHub site, navigate in your fork to the new branch.
135 | 3. Choose the **Pull Request** button at the top of the page.
136 | 4. Verify the Base branch is `microsoftgraph/@master` and the Head branch is `/@`.
137 | 5. Choose the **Update Commit Range** button.
138 | 6. Add a title to your pull request, and describe all the changes you're making.
139 | 7. Submit the pull request.
140 |
141 | One of the site administrators will process your pull request. Your pull request will surface on the microsoftgraph/ site under Issues. When the pull request is accepted, the issue will be resolved.
142 |
143 | #### Create a new branch after merge
144 |
145 | After a branch is successfully merged (that is, your pull request is accepted), don't continue working in that local branch. This can lead to merge conflicts if you submit another pull request. To do another update, create a new local branch from the successfully merged upstream branch, and then delete your initial local branch.
146 |
147 | For example, if your local branch X was successfully merged into the OfficeDev/microsoft-graph-docs master branch and you want to make additional updates to the content that was merged. Create a new local branch, X2, from the OfficeDev/microsoft-graph-docs master branch. To do this, open GitBash and execute the following commands:
148 |
149 | cd microsoft-graph-docs
150 | git pull upstream master:X2
151 | git push origin X2
152 |
153 | You now have local copies (in a new local branch) of the work that you submitted in branch X. The X2 branch also contains all the work other writers have merged, so if your work depends on others' work (for example, shared images), it is available in the new branch. You can verify that your previous work (and others' work) is in the branch by checking out the new branch...
154 |
155 | git checkout X2
156 |
157 | ...and verifying the content. (The `checkout` command updates the files in `C:\Users\\microsoft-graph-docs` to the current state of the X2 branch.) Once you check out the new branch, you can make updates to the content and commit them as usual. However, to avoid working in the merged branch (X) by mistake, it's best to delete it (see the following **Delete a branch** section).
158 |
159 | #### Delete a branch
160 |
161 | Once your changes are successfully merged into the main repository, delete the branch you used because you no longer need it. Any additional work should be done in a new branch.
162 |
163 | #### To delete a branch
164 |
165 | 1. In the Git Bash command prompt, type `git checkout master`. This ensures that you aren't in the branch to be deleted (which isn't allowed).
166 | 2. Next, at the command prompt, type `git branch -d `. This deletes the branch on your computer only if it has been successfully merged to the upstream repository. (You can override this behavior with the `–D` flag, but first be sure you want to do this.)
167 | 3. Finally, type `git push origin :` at the command prompt (a space before the colon and no space after it). This will delete the branch on your github fork.
168 |
169 | Congratulations, you have successfully contributed to the project!
170 |
171 | ## How to use Markdown to format your topic
172 |
173 | ### Article template
174 |
175 | The [markdown template](/articles/0-markdown-template-for-new-articles.md) contains the basic Markdown for a topic that includes a table of contents, sections with subheadings, links to other Office developer topics, links to other sites, bold text, italic text, numbered and bulleted lists, code snippets, and images.
176 |
177 |
178 | ### Standard Markdown
179 |
180 | All of the articles in this repository use Markdown. A complete introduction (and listing of all the syntax) can be found at [Markdown Home] [].
181 |
182 | ## FAQ
183 |
184 | ### How do I get a GitHub account?
185 |
186 | Fill out the form at [Join GitHub](https://github.com/join) to open a free GitHub account.
187 |
188 | ### Where do I get a Contributor's License Agreement?
189 |
190 | You will automatically be sent a notice that you need to sign the Contributor's License Agreement (CLA) if your pull request requires one.
191 |
192 | As a community member, **you must sign the Contribution License Agreement (CLA) before you can contribute large submissions to this project**. You only need complete and submit the documentation once. Carefully review the document. You may be required to have your employer sign the document.
193 |
194 | ### What happens with my contributions?
195 |
196 | When you submit your changes, via a pull request, our team will be notified and will review your pull request. You will receive notifications about your pull request from GitHub; you may also be notified by someone from our team if we need more information. We reserve the right to edit your submission for legal, style, clarity, or other issues.
197 |
198 | ### Can I become an approver for this repository's GitHub pull requests?
199 |
200 | Currently, we are not allowing external contributors to approve pull requests in this repository.
201 |
202 | ### How soon will I get a response about my change request or issue?
203 |
204 | We typically review pull requests and respond to issues within 10 business days.
205 |
206 | ## More resources
207 |
208 | * To learn more about Markdown, go to the Git creator's site [Daring Fireball].
209 | * To learn more about using Git and GitHub, first check out the [GitHub Help section] [GitHub Help].
210 |
211 | [GitHub Home]: http://github.com
212 | [GitHub Help]: http://help.github.com/
213 | [Set Up Git]: http://help.github.com/win-set-up-git/
214 | [Markdown Home]: http://daringfireball.net/projects/markdown/
215 | [Daring Fireball]: http://daringfireball.net/
216 |
--------------------------------------------------------------------------------