Skip to content

Commit d90b5f9

Browse files
Add OAuth token-based authentication to guide (#1245)
1 parent 7d2a9c7 commit d90b5f9

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

content/en/docs/guides/auth.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ passed to the factory method.
112112
configured for POSIX filesystems.
113113
{{% /alert %}}
114114
115+
#### Using OAuth token-based authentication
116+
117+
OAuth 2.0 Protocol is the industry-standard protocol for authorization. It enables
118+
websites or applications to obtain limited access to user accounts using OAuth tokens.
119+
120+
gRPC offers a set of simple APIs to integrate OAuth 2.0 into applications, streamlining authentication.
121+
122+
At a high level, using OAuth token-based authentication includes 3 steps:
123+
124+
1. Get or generate an OAuth token on client side.
125+
* You can generate Google-specific tokens following instructions below.
126+
2. Create credentials with the OAuth token.
127+
* OAuth token is always part of per-call credentials, you can also attach the per-call credentials
128+
to some channel credentials.
129+
* The token will be sent to server, normally as part of HTTP Authorization header.
130+
3. Server side verifies the token.
131+
* In most implementations, the validation is done using a server side interceptor.
132+
133+
For details of how to use OAuth token in different languages, please refer to our examples below.
134+
115135
#### Using Google token-based authentication
116136
117137
gRPC applications can use a simple API to create a credential that works for
@@ -201,6 +221,27 @@ and authorization in various languages.
201221
[Python Example]: https://github.com/grpc/grpc/tree/master/examples/python/auth
202222
[Python Documentation]: https://github.com/grpc/grpc/tree/master/examples/python/auth#authentication-extension-example-in-grpc-python
203223
224+
### Language guides and examples for OAuth token-based authentication
225+
226+
The following table links to examples demonstrating OAuth token-based
227+
authentication and authorization in various languages.
228+
229+
| Language | Example | Documentation |
230+
|----------|-------------------------------------------|-------------------------------|
231+
| C++ | N/A | N/A |
232+
| Go | [Go OAuth Example] | [Go OAuth Documentation] |
233+
| Java | [Java OAuth Example] | [Java OAuth Documentation] |
234+
| Python | [Python OAuth Example] | [Python OAuth Documentation] |
235+
236+
237+
[Go OAuth Example]: https://github.com/grpc/grpc-go/tree/master/examples/features/authentication#authentication
238+
[Go OAuth Documentation]: https://github.com/grpc/grpc-go/tree/master/examples/features/authentication#oauth2
239+
[Java OAuth Example]: https://github.com/grpc/grpc-java/tree/master/examples/example-oauth#authentication-example
240+
[Java OAuth Documentation]: https://github.com/grpc/grpc-java/tree/master/examples/example-oauth
241+
[Python OAuth Example]: https://github.com/grpc/grpc/blob/master/examples/python/auth/token_based_auth_client.py
242+
[Python OAuth Documentation]: https://github.com/grpc/grpc/tree/master/examples/python/auth#token-based-authentication
243+
244+
204245
### Additional Examples
205246
206247
The following sections demonstrate how authentication and authorization features
@@ -265,7 +306,7 @@ var ssl_creds = grpc.credentials.createSsl(root_certs);
265306
});
266307
```
267308

268-
##### Authenticate with Google using Oauth2 token (legacy approach)
309+
##### Authenticate with Google using OAuth2 token (legacy approach)
269310

270311
```js
271312
var GoogleAuth = require('google-auth-library'); // from https://www.npmjs.com/package/google-auth-library
@@ -333,7 +374,7 @@ $opts = [
333374
$client = new helloworld\GreeterClient('greeter.googleapis.com', $opts);
334375
```
335376

336-
##### Authenticate with Google using Oauth2 token (legacy approach)
377+
##### Authenticate with Google using OAuth2 token (legacy approach)
337378

338379
```php
339380
// the environment variable "GOOGLE_APPLICATION_CREDENTIALS" needs to be set

0 commit comments

Comments
 (0)