Skip to content

Commit

Permalink
Merge branch 'release/v1.3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
guruahn committed Mar 11, 2019
2 parents c0d6fc6 + ef6e8be commit 60c7c3d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# vue-google-oauth2
Handling Google sign-in and sign-out for Vue.js applications.
Forked from https://github.com/TinyNova/vue-google-oauth


## Installation
Expand Down Expand Up @@ -38,7 +37,7 @@ Please Don't use `plus.login` scope. [It will be deprecated.](https://developers
## Methods
| Property | Description | Type |
|--------------|--------------------|----------|
| GoogleAuth | return of gapi.auth2.getAuthInstance() | Object |
| GoogleAuth | return of [gapi.auth2.getAuthInstance()](https://developers.google.com/identity/sign-in/web/reference#gapiauth2authresponse) | Object |
| isAuthorized | Whether or not you have auth | Boolean |
| isInit | Whether or not api init | Boolean |
| isLoaded | Whether or not api init. will be deprecated. | Function |
Expand Down Expand Up @@ -70,6 +69,9 @@ this.$gAuth.signIn()
.then(GoogleUser => {
// On success do something, refer to https://developers.google.com/api-client-library/javascript/reference/referencedocs#googleusergetid
console.log('user', GoogleUser)
// GoogleUser.getId() : Get the user's unique ID string.
// GoogleUser.getBasicProfile() : Get the user's basic profile information.
// GoogleUser.getAuthResponse() : Get the response object from the user's auth session. access_token and so on
this.isSignIn = this.$gAuth.isAuthorized
})
.catch(error => {
Expand Down Expand Up @@ -107,6 +109,7 @@ curl -d "client_id=YOUR_CLIENT_ID&\

### Sample Code
- [Golang](https://github.com/guruahn/vue-google-oauth2/blob/master/backend-samples/golang/main.go)
- [Python](https://github.com/guruahn/vue-google-oauth2/blob/master/backend-samples/python/main.py)

## Additional Help
- [sample login page HTML file](https://github.com/guruahn/vue-google-oauth2/blob/master/sample.html).
Expand Down
21 changes: 21 additions & 0 deletions backend-samples/python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# python example for the exchange of auth code to refresh token
# Reference: https://oauth2client.readthedocs.io/en/latest/source/oauth2client.client.html#

from oauth2client import client

CLIENT_ID = 'YOUR_CLIENT_ID'

CLIENT_SECRET = 'YOUR_CLIENT_SECRET'


if __name__ == "__main__":
auth_code = 'auth_code_from_client'

try:
credentials = client.credentials_from_code(CLIENT_ID, CLIENT_SECRET, scope='', code=auth_code)
except client.FlowExchangeError as e:
print(e)
else:
print('refresh_token:', credentials.refresh_token)
print('access_token:', credentials.access_token)
print('token_expiry:', credentials.token_expiry)
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var googleAuth = (function () {
var script = document.createElement('script')
script.src = apiUrl
script.onreadystatechange = script.onload = function () {
if (!script.readyState || /loaded|compvare/.test(script.readyState)) {
if (!script.readyState || /loaded|complete/.test(script.readyState)) {
setTimeout(function () {
resolve()
}, 500)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-google-oauth2",
"version": "1.3.2",
"version": "1.3.3",
"description": "Handling Google Auth2 sign-in and sign-out",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 60c7c3d

Please sign in to comment.