Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
144
Merge Requests
144
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
9f37af6d
Commit
9f37af6d
authored
Oct 03, 2016
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_oauth_google_login: Small improvements
parent
b8d5d6c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
bt5/erp5_oauth_google_login/ExtensionTemplateItem/portal_components/extension.erp5.GoogleLoginUtility.py
...em/portal_components/extension.erp5.GoogleLoginUtility.py
+5
-3
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_receiveGoogleCallback.py
...erp5_oauth_google_login/ERP5Site_receiveGoogleCallback.py
+1
-1
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_redirectToGoogleLoginPage.py
..._oauth_google_login/ERP5Site_redirectToGoogleLoginPage.py
+1
-1
No files found.
bt5/erp5_oauth_google_login/ExtensionTemplateItem/portal_components/extension.erp5.GoogleLoginUtility.py
View file @
9f37af6d
...
...
@@ -5,6 +5,7 @@ import httplib2
import
apiclient.discovery
import
oauth2client.client
import
socket
from
zLOG
import
LOG
,
ERROR
def
getAccessTokenFromCode
(
self
,
code
,
redirect_uri
):
connection_kw
=
{
'host'
:
'accounts.google.com'
,
'timeout'
:
30
}
...
...
@@ -29,8 +30,8 @@ def getAccessTokenFromCode(self, code, redirect_uri):
try
:
body
=
json
.
loads
(
response
.
read
())
except
Exception
:
return
status
,
None
except
Exception
,
error_str
:
return
status
,
{
"error"
:
error_str
}
try
:
return
status
,
body
...
...
@@ -45,8 +46,9 @@ def getUserId(access_token):
).
authorize
(
httplib2
.
Http
())
service
=
apiclient
.
discovery
.
build
(
"oauth2"
,
"v1"
,
http
=
http
)
google_entry
=
service
.
userinfo
().
get
().
execute
()
except
Exception
:
except
Exception
,
error_str
:
google_entry
=
None
LOG
(
"GoogleLoginUtility"
,
ERROR
,
error_str
)
finally
:
socket
.
setdefaulttimeout
(
timeout
)
...
...
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_receiveGoogleCallback.py
View file @
9f37af6d
...
...
@@ -14,7 +14,7 @@ elif code is not None:
status
,
response_dict
=
context
.
ERP5Site_getAccessTokenFromCode
(
code
,
"{0}/ERP5Site_receiveGoogleCallback"
.
format
(
portal
.
absolute_url
()))
if
status
!=
200
:
if
status
!=
200
and
response_dict
is
not
None
:
return
handleError
(
" "
.
join
([
"%s : %s"
%
(
k
,
v
)
for
k
,
v
in
response_dict
.
iteritems
()]))
if
response_dict
is
not
None
:
...
...
bt5/erp5_oauth_google_login/SkinTemplateItem/portal_skins/erp5_oauth_google_login/ERP5Site_redirectToGoogleLoginPage.py
View file @
9f37af6d
...
...
@@ -8,4 +8,4 @@ query = make_query({
'scope'
:
'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
})
context
.
REQUEST
.
RESPONSE
.
redirect
(
'''https://accounts.google.com/o/oauth2/auth?'''
+
query
)
context
.
REQUEST
.
RESPONSE
.
redirect
(
"https://accounts.google.com/o/oauth2/auth?"
+
query
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment