Custom Security using Google OAuth Prefab
In this section, we will be seeing how to validate Google Login using Custom Security within WaveMaker App and to access Gmail API. Steps to attain this include:
- Using OAuth Prefab for Google to get the access token for the Google user to access Google API – oauth2 API.
- Use the spring-social-google dependency from spring framework.
- To validate the login through Google, a Java Service will be created which will override WMCustomAuthenticationManager
- The access token from the OAuth prefab will be used as an id in the WMUser object returned by the Java Service.
We have used the following Java code to accomplish this.
- Dependency in pom.xml file
- Imports of Java Service – class definition:
- Java Class – Method Definition:
- Create an action Login variable. In our example we have named it "googleLoginAction". In the JavaScript Onaccesstokenfetch event for Google Prefab, add the JS snippet below: