Send feedback
Stay organized with collections
Save and categorize content based on your preferences.
Version latest keyboard_arrow_down
Signet
Homepage
https://github.com/googleapis/signet/
Author
Bob Aman
Copyright
Copyright © 2010 Google, Inc.
License
Apache 2.0
Description
Signet is an OAuth 1.0 / OAuth 2.0 implementation.
Reference
{Signet::OAuth1}
{Signet::OAuth1::Client}
{Signet::OAuth1::Credential}
{Signet::OAuth1::Server}
{Signet::OAuth2}
{Signet::OAuth2::Client}
Example Usage for Google
Initialize the client
require 'signet/oauth_2/client'
client = Signet::OAuth2:: Client
.new(
:authorization_uri => 'https://accounts.google.com/o/oauth2/auth',
:token_credential_uri => 'https://oauth2.googleapis.com/token',
:client_id => "#{YOUR_CLIENT_ID}.apps.googleusercontent.com",
:client_secret => YOUR_CLIENT_SECRET,
:scope => 'email profile',
:redirect_uri => 'https://example.client.com/oauth'
)
Request an authorization code
redirect_to(client.authorization_uri)
Obtain an access token
client.code = request.query['code']
client.fetch_access_token!
Install
gem install signet
Be sure https://rubygems.org
is in your gem sources.
Supported Ruby Versions
This library is supported on Ruby 3.0+.
Google provides official support for Ruby versions that are actively supported
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
in security maintenance, and not end of life. Older versions of Ruby may
still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/
for details about the Ruby
support schedule.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-04 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["Version latestkeyboard_arrow_down\n\n- [0.21.0 (latest)](/ruby/docs/reference/signet/latest)\n- [0.20.0](/ruby/docs/reference/signet/0.20.0) \n\nSignet\n======\n\nHomepage\n: \u003chttps://github.com/googleapis/signet/\u003e\n\nAuthor\n: [Bob Aman](mailto:bobaman@google.com)\n\nCopyright\n: Copyright © 2010 Google, Inc.\n\nLicense\n: Apache 2.0\n\n[](https://badge.fury.io/rb/signet)\n\nDescription\n-----------\n\nSignet is an OAuth 1.0 / OAuth 2.0 implementation.\n\nReference\n---------\n\n- {Signet::OAuth1}\n- {Signet::OAuth1::Client}\n- {Signet::OAuth1::Credential}\n- {Signet::OAuth1::Server}\n- {Signet::OAuth2}\n- {Signet::OAuth2::Client}\n\nExample Usage for Google\n------------------------\n\nInitialize the client\n=====================\n\n require 'signet/oauth_2/client'\n client = Signet::OAuth2::https://cloud.google.com/ruby/docs/reference/signet/latest/Signet-OAuth2-Client.html.new(\n :authorization_uri =\u003e 'https://accounts.google.com/o/oauth2/auth',\n :token_credential_uri =\u003e 'https://oauth2.googleapis.com/token',\n :client_id =\u003e \"#{YOUR_CLIENT_ID}.apps.googleusercontent.com\",\n :client_secret =\u003e YOUR_CLIENT_SECRET,\n :scope =\u003e 'email profile',\n :redirect_uri =\u003e 'https://example.client.com/oauth'\n )\n\nRequest an authorization code\n=============================\n\n redirect_to(client.authorization_uri)\n\nObtain an access token\n======================\n\n client.code = request.query['code']\n client.fetch_access_token!\n\nInstall\n-------\n\n`gem install signet`\n\nBe sure `https://rubygems.org` is in your gem sources.\n\nSupported Ruby Versions\n-----------------------\n\nThis library is supported on Ruby 3.0+.\n\nGoogle provides official support for Ruby versions that are actively supported\nby Ruby Core---that is, Ruby versions that are either in normal maintenance or\nin security maintenance, and not end of life. Older versions of Ruby *may*\nstill work, but are unsupported and not recommended. See\n\u003chttps://www.ruby-lang.org/en/downloads/branches/\u003e for details about the Ruby\nsupport schedule."]]