diff --git a/README.md b/README.md index 6621400..2dcf346 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 | @@ -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 => { @@ -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). diff --git a/backend-samples/python/main.py b/backend-samples/python/main.py new file mode 100644 index 0000000..d2d6af8 --- /dev/null +++ b/backend-samples/python/main.py @@ -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) diff --git a/index.js b/index.js index 8eaf3b0..5eb6cde 100644 --- a/index.js +++ b/index.js @@ -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) diff --git a/package.json b/package.json index 00d987b..fa0dcc0 100644 --- a/package.json +++ b/package.json @@ -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": {