Omniauth-Stripe-Connect 开源项目教程

Omniauth-Stripe-Connect 开源项目教程

omniauth-stripe-connectStripe Connect OAuth2 Strategy for OmniAuth 1.0项目地址:https://gitcode.com/gh_mirrors/om/omniauth-stripe-connect

1. 项目的目录结构及介绍

omniauth-stripe-connect/
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── README.md
├── Rakefile
├── lib/
│   ├── omniauth/
│   │   ├── strategies/
│   │   │   └── stripe_connect.rb
│   └── omniauth-stripe_connect.rb
├── omniauth-stripe_connect.gemspec
└── spec/
    ├── omniauth/
    │   ├── strategies/
    │   │   └── stripe_connect_spec.rb
    └── spec_helper.rb
  • GemfileGemfile.lock:定义了项目的依赖关系。
  • LICENSE:项目的许可证。
  • README.md:项目的说明文档。
  • Rakefile:用于定义Rake任务。
  • lib/:包含项目的主要代码。
    • omniauth/:OmniAuth策略的目录。
      • strategies/:具体的策略实现。
        • stripe_connect.rb:Stripe Connect的策略实现。
    • omniauth-stripe_connect.rb:项目的主文件。
  • omniauth-stripe_connect.gemspec:项目的gemspec文件,定义了gem的元数据。
  • spec/:包含测试文件。
    • omniauth/:测试策略的目录。
      • strategies/:具体的策略测试。
        • stripe_connect_spec.rb:Stripe Connect策略的测试。
    • spec_helper.rb:测试辅助文件。

2. 项目的启动文件介绍

项目的启动文件是 lib/omniauth-stripe_connect.rb,它负责加载OmniAuth的Stripe Connect策略。

require "omniauth"
require "omniauth-oauth2"

module OmniAuth
  module Strategies
    class StripeConnect < OmniAuth::Strategies::OAuth2
      option :name, "stripe_connect"
      option :client_options, {
        :site => "https://connect.stripe.com",
        :authorize_url => "/oauth/authorize",
        :token_url => "/oauth/token"
      }

      uid { raw_info['id'] }

      info do
        {
          :name => raw_info['display_name'],
          :email => raw_info['email'],
          :scope => raw_info['scope']
        }
      end

      extra do
        {
          :raw_info => raw_info
        }
      end

      def raw_info
        @raw_info ||= access_token.get('/v1/account').parsed
      end
    end
  end
end

OmniAuth.config.add_camelization 'stripe_connect', 'StripeConnect'

3. 项目的配置文件介绍

项目的配置文件主要是 omniauth-stripe_connect.gemspec,它定义了gem的元数据和依赖关系。

Gem::Specification.new do |spec|
  spec.name          = "omniauth-stripe-connect"
  spec.version       = "1.0.0"
  spec.authors       = ["Isaac Sanders"]
  spec.email         = ["isaac@isaacbfsanders.com"]
  spec.description   = %q{OmniAuth strategy for Stripe Connect.}
  spec.summary       = %q{OmniAuth strategy for Stripe Connect.}
  spec.homepage      = "https://github.com/isaacsanders/omniauth-stripe-connect"
  spec.license       = "MIT"

  spec.files         = `git ls-files`.split($/)
  spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
  spec.require_paths = ["lib"]

  spec.add_dependency "omniauth", "~> 1.0"
  spec.add_dependency "omniauth-oauth2", "~> 1.1"

  spec.add_development_dependency "bundler", "~> 1.3"
  spec.add_development_dependency "rake"
  spec.add_development_dependency "rspec", "~> 3.0"
end

这个文件定义了gem的名称、版本、作者、描述、依赖关系等信息。

omniauth-stripe-connectStripe Connect OAuth2 Strategy for OmniAuth 1.0项目地址:https://gitcode.com/gh_mirrors/om/omniauth-stripe-connect

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

邱进斌Olivia

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值