コード例 #1
0
ファイル: functions.py プロジェクト: sportsbitenews/gridspree
def _get_client():
    return OAuth2(client_id=settings.GOOGLE_CLIENT_ID,
                  client_secret=settings.GOOGLE_CLIENT_SECRET,
                  site="https://accounts.google.com/o/",
                  redirect_uri=settings.SERVICE_URL + url_for("auth.auth"),
                  authorization_url='oauth2/auth',
                  token_url='oauth2/token')
コード例 #2
0
ファイル: clio.py プロジェクト: rosscdh/python-goclio
 def __init__(self, client_id, client_secret, redirect_uri, **kwargs):
     self.access_token = None  # reset
     self.client = OAuth2(client_id=client_id,
                          client_secret=client_secret,
                          site=self.site,
                          redirect_uri=redirect_uri,
                          authorization_url=kwargs.get(
                              'authorization_url', self.authorization_url),
                          token_url=kwargs.get('token_url', self.token_url))
コード例 #3
0
ファイル: views.py プロジェクト: jnayak1/OSF_meetings_django
 def get(self, request, format=None):
     client_id = 'd5c46638ed1d42b9977264d084875c5a'
     client_secret = 'Pxsc1AeBDHBNK5dNCrqjvYkonBKMXXSvNSoDyK84'
     oauth2_handler = OAuth2(client_id,
                             client_secret,
                             "https://staging-accounts.osf.io/",
                             "http://localhost:8000/login",
                             authorization_url='oauth2/authorize')
     authorization_url = oauth2_handler.authorize_url(
         'osf.full_read osf.full_write', response_type='code')
     return Response(authorization_url)
コード例 #4
0
    def __init__(self,
                 client_id,
                 client_secret,
                 code=None,
                 access_token=None,
                 storage=MemoryStorage()):
        self.oauth2 = OAuth2(client_id=client_id,
                             client_secret=client_secret,
                             site="{0}://{1}/".format(self.protocol,
                                                      self.host),
                             redirect_uri="http://localhost",
                             authorization_url="oauth2/authorize",
                             token_url="oauth2/token")
        self.storage = storage

        if code:
            self._get_token(code=code)

        if access_token:
            self.storage.set(access_token=access_token, token_type="")
コード例 #5
0
from django.shortcuts import render_to_response
from django.template import RequestContext

from gitzen.enhancement_tracking.cache_actions import (build_cache_index,
                                                       update_cache_index)
from gitzen.enhancement_tracking.forms import (
    NewUserForm, NewGroupSuperuserForm, NewAPIAccessDataForm,
    ChangeAPIAccessDataForm, UserProfileForm, ActiveUserSelectionForm,
    InactiveUserSelectionForm)
from gitzen.enhancement_tracking.models import UserProfile

# Constant OAuth handler and authorization URL for access to GitHub's OAuth.
OAUTH2_HANDLER = OAuth2(settings.CLIENT_ID,
                        settings.CLIENT_SECRET,
                        site='https://github.com/',
                        redirect_uri='%s/confirm_git_oauth' %
                        settings.ABSOLUTE_SITE_URL,
                        authorization_url='login/oauth/authorize',
                        token_url='login/oauth/access_token')
GIT_AUTH_URL = OAUTH2_HANDLER.authorize_url('repo')

# Email message that is sent to new users after a group superuser has created a
# user account for them in their group. The message prompts the user to change
# the random password that was assigned to their account upon creation.
NEW_USER_EMAIL_MESSAGE = \
    "A user account has been created for you on GitZen for the product " \
    "%(product_name)s. This account will allow you to track the progress of " \
    "enhancments for this product as they move through different stages in " \
    "GitHub and Zendesk.\n\n" \
    "The username and password for your account are listed bellow. The " \
    "password was automatically generated during your account's creation, " \
コード例 #6
0
ファイル: utils.py プロジェクト: xobb1t/djangolint
def get_oauth_handler():
    GITHUB = settings.GITHUB
    return OAuth2(
        GITHUB['CLIENT_ID'], GITHUB['CLIENT_SECRET'], GITHUB['AUTH_URL'],
        '', GITHUB['AUTHORIZE_URL'], GITHUB['TOKEN_URL']
    )
コード例 #7
0
ファイル: gmail.py プロジェクト: rahinj/dwightassistant
from requests_oauth2 import OAuth2
import os
import utils
import dynamodb
import json
from urllib import quote, urlencode
import base64
import base_service
import base64
service = "gmail"
base_service = base_service.BaseService(service)
redirect_uri = utils.get_api_auth_url(service)
client_id = os.environ['GMAIL_CLIENT_ID']
client_secret = os.environ['GMAIL_CLIENT_SECRET']
auth_base = "https://accounts.google.com/o/oauth2/"
oauth2_handler = OAuth2(client_id, client_secret, auth_base, redirect_uri,
                        "auth", "token")
authorization_url = oauth2_handler.authorize_url(
    'email https://www.googleapis.com/auth/gmail.modify'
) + "&response_type=code&access_type=offline&prompt=consent"


def get_and_save_access_code(code, user_id):
    command = "curl https://www.googleapis.com/oauth2/v4/token -d 'code={0}' -d 'client_id={1}' -d 'client_secret={2}' -d 'redirect_uri={3}' -d 'grant_type=authorization_code'".format(
        code, client_id, client_secret, redirect_uri)
    print(command)
    return base_service.get_and_save_access_code(user_id, command)


def save_access_token(event):
    code = event["queryStringParameters"]["code"]
    user_id = event["headers"]["Cookie"].split("=")[-1]
コード例 #8
0
 def __init__(self, client_id, client_secret, redirect_url):
     self.oauth2 = OAuth2(client_id, client_secret, self.AUTH_URL_BASE,
                          redirect_url, self.AUTH_URL_NEW,
                          self.AUTH_URL_TOKEN)
コード例 #9
0
ファイル: spotify.py プロジェクト: rahinj/dwightassistant
from requests_oauth2 import OAuth2
import os
import utils
import dynamodb
import json
from urllib import quote, urlencode
import base64
import base_service
service = "spotify"
base_service = base_service.BaseService(service)
redirect_uri = utils.get_api_auth_url(service)
client_id = os.environ['SPOTIFY_CLIENT_ID']
client_secret = os.environ['SPOTIFY_CLIENT_SECRET']
oauth2_handler = OAuth2(client_id, client_secret,
                        "https://accounts.spotify.com/", redirect_uri,
                        "authorize", "api/token")
authorization_url = oauth2_handler.authorize_url(
    'user-read-playback-state user-read-private user-read-currently-playing user-modify-playback-state'
) + "&response_type=code"


def save_access_token(event):
    code = event["queryStringParameters"]["code"]
    user_id = event["headers"]["Cookie"].split("=")[-1]
    res = get_and_save_access_code(code, user_id)
    return {
        'statusCode':
        '200',
        'body':
        json.dumps(
            {"message": "Spotify Connected, Now you can go back to chatbot!"}),
コード例 #10
0
ファイル: intra.py プロジェクト: vboiko-gt/ForFun
import urllib3
from requests_oauth2 import OAuth2

auth = OAuth2('', authorization_url='https://api.intra.42.fr', token_url='oauth/token')
token = auth.token_url

print(token)