How to use the onedrivesdk.helpers.GetAuthCodeServer.get_auth_code function in onedrivesdk

To help you get started, we’ve selected a few onedrivesdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blockstack / blockstack-core / integration_tests / blockstack_integration_tests / scenarios / blockstack_client / backend / drivers / onedrive.py View on Github external
dirp = os.path.dirname(session_path)
        if not os.path.exists(dirp):
            try:
                os.makedirs(dirp)
                os.chmod(dirp, 0700)
            except Exception as e:
                if DEBUG:
                    log.exception(e)

                log.error("Failed to make directories to store session")
                return None

        # log in
        auth_url = client.auth_provider.get_auth_url(REDIRECT_URL)

        code = GetAuthCodeServer.get_auth_code(auth_url, REDIRECT_URL)
        client.auth_provider.authenticate(code, REDIRECT_URL, CLIENT_SECRET)

        # save for future user 
        client.auth_provider.save_session(path=session_path)

    ONEDRIVE_HANDLE = client
    return client
github epam / OneDrive-L / onedrive_service / src / onedrive_service / authentication / one_drive_client.py View on Github external
def authenticate(self, client_secret=None,
                     redirect_uri='http://localhost:8080/', auth_code=None):
        """ Authenticate process for OneDrive for personal use.
        """

        if client_secret is None:
            client_secret = self._config['auth']['client_secret']

        if self.check_saved_session_exists():
            self.auth_provider.load_session()
        else:
            if auth_code is None:
                auth_url = self.auth_provider.get_auth_url(redirect_uri)
                auth_code = GetAuthCodeServer.\
                    get_auth_code(auth_url, redirect_uri)

            self.auth_provider.\
                authenticate(auth_code, redirect_uri, client_secret)
            self.auth_provider.save_session()
github eyadgaran / SimpleML / simpleml / persistables / saving.py View on Github external
def authenticate_onedrive(self):
        '''
        Authenticate with Onedrive Oauth2
        '''
        from onedrivesdk.helpers.GetAuthCodeServer import get_auth_code

        section = CONFIG[ONEDRIVE_SECTION]
        redirect_uri = section.get('redirect_uri')
        client_secret = section.get('client_secret')
        client_id = section.get('client_id')
        scopes = section.getlist('scopes')

        client = onedrivesdk.get_default_client(client_id=client_id, scopes=scopes)
        auth_url = client.auth_provider.get_auth_url(redirect_uri)
        # Block thread until we have the code
        code = get_auth_code(auth_url, redirect_uri)
        # Finally, authenticate!
        client.auth_provider.authenticate(code, redirect_uri, client_secret)

        self.client = client
github niqdev / packtpub-crawler / script / onedrive.py View on Github external
def __save_credentials(self, session_file):
        # api_base_url = self.__config.get('onedrive', 'onedrive.api_base_url')
        redirect_uri = 'http://localhost:8080/'
        client_id = self.__config.get('onedrive', 'onedrive.client_id')
        client_secret = self.__config.get('onedrive', 'onedrive.client_secret')

        client = onedrivesdk.get_default_client(client_id=client_id, scopes=self.__scopes)

        auth_url = client.auth_provider.get_auth_url(redirect_uri)

        # this will block until we have the code
        code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)

        client.auth_provider.authenticate(code, redirect_uri, client_secret)

        # Save the session for later
        client.auth_provider.save_session(path=session_file)
        log_info('[+] new credentials saved')