Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
334992cc
Commit
334992cc
authored
May 31, 2013
by
Kostas Papadimitriou
Browse files
astakos: Configurable third party provider endpoints
not so often, but providers do seem to change urls
parent
87d30dc1
Changes
3
Hide whitespace changes
Inline
Side-by-side
snf-astakos-app/astakos/im/views/target/google.py
View file @
334992cc
...
...
@@ -32,35 +32,47 @@
# or implied, of GRNET S.A.
import
json
import
logging
import
urllib
import
oauth2
as
oauth
from
django.utils.translation
import
ugettext
as
_
from
django.contrib
import
messages
from
django.views.decorators.http
import
require_http_methods
from
django.http
import
HttpResponseRedirect
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
as
django_settings
from
astakos.im.models
import
AstakosUser
from
astakos.im
import
settings
from
astakos.im.views.target
import
get_pending_key
,
\
handle_third_party_signup
,
handle_third_party_login
,
init_third_party_session
handle_third_party_signup
,
handle_third_party_login
,
\
init_third_party_session
from
astakos.im.views.decorators
import
cookie_fix
,
requires_auth_provider
import
logging
import
urllib
logger
=
logging
.
getLogger
(
__name__
)
import
oauth2
as
oauth
signature_method
=
oauth
.
SignatureMethod_HMAC_SHA1
()
OAUTH_CONSUMER_KEY
=
settings
.
GOOGLE_CLIENT_ID
OAUTH_CONSUMER_SECRET
=
settings
.
GOOGLE_SECRET
token_scope
=
'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
authenticate_url
=
'https://accounts.google.com/o/oauth2/auth'
access_token_url
=
'https://www.googleapis.com/oauth2/v1/tokeninfo'
request_token_url
=
'https://accounts.google.com/o/oauth2/token'
def
django_setting
(
key
,
default
):
return
getattr
(
django_settings
,
'GOOGLE_%s'
%
key
.
upper
,
default
)
default_token_scopes
=
[
'https://www.googleapis.com/auth/userinfo.profile'
,
'https://www.googleapis.com/auth/userinfo.email'
]
token_scope
=
django_setting
(
'token_scope'
,
' '
.
join
(
default_token_scopes
))
authenticate_url
=
django_setting
(
'authenticate_url'
,
'https://accounts.google.com/o/oauth2/auth'
)
access_token_url
=
django_setting
(
'access_token_url'
,
'https://www.googleapis.com/oauth2/v1/tokeninfo'
)
request_token_url
=
django_setting
(
'request_token_url'
,
'https://accounts.google.com/o/oauth2/token'
)
def
get_redirect_uri
():
...
...
snf-astakos-app/astakos/im/views/target/linkedin.py
View file @
334992cc
...
...
@@ -32,30 +32,40 @@
# or implied, of GRNET S.A.
import
json
import
logging
import
oauth2
as
oauth
import
cgi
from
django.contrib
import
messages
from
django.views.decorators.http
import
require_http_methods
from
django.http
import
HttpResponseRedirect
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
as
django_settings
from
astakos.im.models
import
AstakosUser
from
astakos.im
import
settings
from
astakos.im.views.target
import
get_pending_key
,
\
handle_third_party_signup
,
handle_third_party_login
,
init_third_party_session
handle_third_party_signup
,
handle_third_party_login
,
\
init_third_party_session
from
astakos.im.views.decorators
import
cookie_fix
,
\
requires_auth_provider
import
logging
logger
=
logging
.
getLogger
(
__name__
)
import
oauth2
as
oauth
import
cgi
def
django_setting
(
key
,
default
):
return
getattr
(
django_settings
,
'GOOGLE_%s'
%
key
.
upper
,
default
)
request_token_url
=
'https://api.linkedin.com/uas/oauth/requestToken?scope=r_basicprofile+r_emailaddress'
access_token_url
=
'https://api.linkedin.com/uas/oauth/accessToken'
authenticate_url
=
'https://www.linkedin.com/uas/oauth/authorize'
token_scope
=
'r_basicprofile+r_emailaddress'
request_token_url
=
django_setting
(
'request_token_url'
,
'https://api.linkedin.com/uas/oauth/requestToken?scope='
+
token_scope
)
access_token_url
=
django_setting
(
'access_token_url'
,
'https://api.linkedin.com/uas/oauth/accessToken'
)
authenticate_url
=
django_setting
(
'authenticate_url'
,
'https://www.linkedin.com/uas/oauth/authorize'
)
@
requires_auth_provider
(
'linkedin'
)
...
...
snf-astakos-app/astakos/im/views/target/twitter.py
View file @
334992cc
...
...
@@ -32,11 +32,15 @@
# or implied, of GRNET S.A.
import
logging
import
oauth2
as
oauth
import
cgi
import
urllib
from
django.contrib
import
messages
from
django.views.decorators.http
import
require_http_methods
from
django.http
import
HttpResponseRedirect
,
urlencode
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
as
django_settings
from
urlparse
import
urlunsplit
,
urlsplit
,
parse_qsl
...
...
@@ -47,16 +51,22 @@ from astakos.im.views.target import get_pending_key, \
init_third_party_session
from
astakos.im.views.decorators
import
cookie_fix
,
requires_auth_provider
logger
=
logging
.
getLogger
(
__name__
)
import
oauth2
as
oauth
import
cgi
import
urllib
request_token_url
=
'https://api.twitter.com/oauth/request_token'
access_token_url
=
'https://api.twitter.com/oauth/access_token'
authenticate_url
=
'https://api.twitter.com/oauth/authenticate'
def
django_setting
(
key
,
default
):
return
getattr
(
django_settings
,
'TWITTER_%s'
%
key
.
upper
,
default
)
request_token_url
=
django_setting
(
'request_token_url'
,
'https://api.twitter.com/oauth/request_token'
)
access_token_url
=
django_setting
(
'access_token_url'
,
'https://api.twitter.com/oauth/access_token'
)
authenticate_url
=
django_setting
(
'authenticate_url'
,
'https://api.twitter.com/oauth/authenticate'
)
@
requires_auth_provider
(
'twitter'
)
@
require_http_methods
([
"GET"
,
"POST"
])
...
...
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