Recently i worked on accessing google apis through Service account. It was real fun to work on open source for the reason : little literature is available for this;learned how to use oAuth2.0 protocol for authentication using JWT(JSon Web Token).
Service account in google basically allows application to connect to google apis using the access token received for JWT. So manual intervention of user is eliminated which otherwise is required to authorize request.
Service account basically uses following steps:
- Create JWT(Json web token)
Document for JWT can be found here: https://developers.google.com/accounts/docs/OAuth2ServiceAccount. - Send urlencoded post request to url https://accounts.google.com/o/oauth2/token to get access token.
This will return a Json response containing access token. - Use this access token to call google apis.
- Google Cloud Storage
- Google Prediction API
- Google URL Shortener
- Google OAuth 2.0 Authorization Server
- Google APIs Console
- Google APIs Client Libraries for Python, Java, and PHP
Implementation details:
Used service account to access google+ api.
BoucyCastle libraries are used for SHA256withRSA signing. (this algorithm is supported by framework only on operating systems win 2k3 and above. So used this open source implementation).
Used DataContractJsonSerializer to parse Json response.
Download Code
Comments
Post a Comment