Is there a way to use another OAuth2 provider with Google Cloud Endpoints? I mean for example, get authentication from Facebook and use it the same way we use Google Account Auth (using gapi js and putting User class on @ApiMethod
)
The redirect URIs are the endpoints to which the OAuth 2.0 server can send responses. These endpoints must adhere to Google's validation rules. For testing, you can specify URIs that refer to the local machine, such as http://localhost:8080 .
With a user account, you can authenticate to Google APIs and services in the following ways: Use the gcloud CLI to set up Application Default Credentials (ADC). Use the gcloud CLI to generate access tokens. Use your user credentials to impersonate a service account.
You have to implement your own Authenticator
and update @Api
configuration. Based on this answer a simple authenticator will look like this:
public class MyAuthenticator implements Authenticator {
@Override
public User authenticate(HttpServletRequest request) {
String token = request.getHeader("Authorization");
if (token != null) {
// apply your Facebook/Twitter/OAuth2 authentication
String user = authenticate(token);
if (user != null) {
return new User(user);
}
}
return null;
}
}
And your API definition
@Api(name = "example", authenticators = {MyAuthenticator.class})
More about custom authenticators you can find in Google documentation.
No. I came across someone else asking this question and the answer from the google folks (if I remember correctly) was that the endpoints user authentication currently only supports Google accounts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With