GAuth — implement a Google-specific OAuth consumer
The GAuth component is used by web applications to implement a Google-specific OAuth consumer. Although this component belongs to the Camel Components for Google App Engine (GAE), it can also be used to OAuth-enable non-GAE web applications. For a detailed description of Google's OAuth implementation refer to the Google OAuth API reference.
The URI format for a GAuth endpoint is:
gauth://name
[?options
]
name
can be either authorize
or
upgrade
. An authorize
endpoint is used to obtain an
unauthorized request token from Google and to redirect the user to the authorization page. The
upgrade
endpoint is used to process OAuth callbacks from Google and to
upgrade an authorized request token to a long-lived access token.
Maven users will need to add a dependency on camel-gae
to their poms as
shown in Example 5, “GAuth dependency”.
Example 5. GAuth dependency
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-gae</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency>
Table 16, “GAuth options” lists the options for a GAuth endpoint.
Table 16. GAuth options
Name | Required | Description |
---|---|---|
callback | true
[a] | Specifies the URL to where users are redirected after having granted or denied access. |
scope | true
[b]
| Specifies the URL identifying the service(s) to be accessed. To specify more than one scope, list each one separated with a comma. |
consumerKey | true
[c]
| Specifies the domain identifying the web application. This is the domain used
when registering the application with Google. For a non-registered application use
anonymous . |
consumerSecret | if keyLoaderRef is not
specified[c] | Specifies the consumer secret of the web application. The consumer secret is
generated when registering the application with Google. It is needed if the
HMAC-SHA1 signature method shall be used. For a non-registered application use
anonymous . |
keyLoaderRef | if consumerSecret is not
specified[c] |
Specifies a reference to a private key loader in the registry. The
These classes are defined in the org.apache.camel.component.gae.auth package. |
authorizeBindingRef | false | Specifies a reference to a
OutboundBinding<GAuthEndpoint, GoogleOAuthParameters, GoogleOAuthParameters>
in the registry for customizing how an exchange is bound to
GoogleOAuthParameters . This binding is used for the authorization
phase. |
upgradeBindingRef | false | Specifies a reference to a
OutboundBinding<GAuthEndpoint, GoogleOAuthParameters, GoogleOAuthParameters>
in the registry for customizing how an exchange is bound to
GoogleOAuthParameters . This binding is used for the token upgrade
phase. |
[a] can alternatively be set via the
[b] can alternatively be set via [c] can alternatively be set on component-level |
The following message headers can be used to affect the behavior of the component:
Name | Endpoint | Message | Description |
---|---|---|---|
GAuthAuthorizeBinding.GAUTH_CALLBACK | gauth:authorize | IN | Overrides the callback option. |
GAuthAuthorizeBinding.GAUTH_SCOPE | gauth:authorize | IN | Overrides the scope option. |
GAuthUpgradeBinding.GAUTH_ACCESS_TOKEN | gauth:upgrade | OUT | Contains the long-lived access token. This token should be stored by the applications in context of a user. |
GAuthUpgradeBinding.GAUTH_ACCESS_TOKEN_SECRET | gauth:upgrade | OUT | Contains the access token secret. This token secret should be stored by the applications in context of a user. |