README.md in googleauth-extras-0.1.0 vs README.md in googleauth-extras-0.2.0
- old
+ new
@@ -1,7 +1,10 @@
# googleauth-extras
+[![Gem Version](https://img.shields.io/gem/v/googleauth-extras?color=blue)](https://rubygems.org/gems/googleauth-extras)
+![Build](https://github.com/persona-id/googleauth-extras/workflows/CI/badge.svg)
+
**Disclaimer: This gem is not sponsored by Google.**
The [googleauth](https://github.com/googleapis/google-auth-library-ruby) currently lacks support for all the authentication schemes supported in Python and the `gcloud` CLI. This gem aims to support additional schemes like:
- Impersonated credentials
@@ -28,18 +31,35 @@
### Impersonated Credentials
If you'd like to have credentials that act as a different service account, you can setup the credentials with:
```ruby
-Google::Apis::DriveV3::DriveService.new.tap do |ds|
- ds.authorization = Google::Auth::Extras.impersonated_credential(
+# Old API Client
+Google::Apis::RequestOptions.default.authorization = Google::Auth::Extras.impersonated_authorization(
+ email_address: 'my-sa@my-project.iam.gserviceaccount.com',
+ scope: [
+ Google::Apis::ComputeV1::AUTH_CLOUD_PLATFORM,
+ Google::Apis::PubsubV1::AUTH_PUBSUB,
+ ],
+)
+
+# New API Client
+Google::Cloud.configure.credentials = Google::Auth::Extras.impersonated_credential(
+ email_address: 'my-sa@my-project.iam.gserviceaccount.com',
+ scope: Google::Cloud.configure.pubsub.scope,
+)
+
+# Dual Client Setup
+Google::Cloud.configure.credentials = Google::Auth::Extras.wrap_authorization(
+ Google::Apis::RequestOptions.default.authorization = Google::Auth::Extras.impersonated_authorization(
email_address: 'my-sa@my-project.iam.gserviceaccount.com',
scope: [
- Google::Apis::SheetsV4::AUTH_DRIVE,
+ Google::Apis::ComputeV1::AUTH_CLOUD_PLATFORM,
+ Google::Apis::PubsubV1::AUTH_PUBSUB,
],
)
-end
+)
```
You can optionally specify the following additional options:
- `base_credentials`: The credentials to use to make the impersonation call. If not specified, uses the standard SDK credential resolution process.
@@ -50,13 +70,23 @@
If you'd like to use a static access token, you can setup the credentials with:
```ruby
# Old API Client
-Google::Apis::RequestOptions.default.authorization = Google::Auth::Extras.static_credential('my-access-token')
+Google::Apis::RequestOptions.default.authorization = Google::Auth::Extras.static_authorization('my-access-token')
+
# New API Client
Google::Cloud.configure.credentials = Google::Auth::Extras.static_credential('my-access-token')
+
+# Dual Client Setup
+Google::Cloud.configure.credentials = Google::Auth::Extras.wrap_authorization(
+ Google::Apis::RequestOptions.default.authorization = Google::Auth::Extras.static_authorization('my-access-token')
+)
```
+
+### Authorization vs Credential
+
+The values returned from the `*_authorization` methods will work with both the old and new SDKs, it'll just trigger a warning with the newer SDKs. The reverse however is not true, the values returned from the `*_credential` methods will not work with the old SDKs.
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.