Create OAuth, to be called the first time session tries to authenticate.
173275
BoxCreateAuthRequest createOAuth(String code, String clientId, String clientSecret) {
        BoxCreateAuthRequest request = new BoxCreateAuthRequest(mSession, getTokenUrl(), code, clientId, clientSecret);
        return request;
    }
678672
def create
      # TODO:
      #   * guard based on "state" param:
      #     if `session['omniauth.state]`, `params[:state]` must match.

      authorization = Corkboard::Authorization.create!(auth_attrs)
      subscription  = Corkboard::Subscription.create!(provider, authorization)

      Corkboard.publish!(subscription.backlog)
      redirect_to(authorizations_path)
    end
1195310
def authenticate():
    

    print LOGIN_INIT_MESSAGE

    username = raw_input('{0}: '.format(LOGIN_USER_MESSAGE))
    password = None

    while password is None:
        password = getpass('Password for {0}: '.format(username))

    gh = login(username, password=password)
    try:
        gh.user()
        instance = authorize(username, password, APP_SCOPE, APP_DESC, APP_URL)
    except Exception, e:
        raise e

    with open(credentials_file, 'w') as f:
        f.write(instance.token)

    return instance.token
377460
def authenticate(self):
        """"""
        postdata = self.authentication_postdata
        jar = requests.cookies.cookielib.CookieJar()
        self.cookies = jar
        resp = self.get(self.authentication_base_url)
        authtok = _extract_authenticity_token(resp.content)
        if postdata is None:
            # This works for GitHub
            postdata = {"login": self.oauth2_username,
                        "password": self._oauth2_password,
                        "authenticity_token": authtok,
                        "commit": "Sign+in",
                        "utf8": u"\u2713",
                        }  # pylint: disable=bad-continuation
            self.authentication_postdata = postdata
        if self.authentication_session_url is None:
            # This is also for GitHub
            authentication_session_url = "https://github.com/session"
            self.authentication_session_url = authentication_session_url
        self.post(self.authentication_session_url, data=postdata)
1076842
def refresh(self):
        ""

        # Construct the credentials for the verification request
        oauth = OAuth1(
            self.consumer_key,
            client_secret=self.consumer_secret,
            resource_owner_key=self.oauth_token,
            resource_owner_secret=self.oauth_token_secret,
            rsa_key=self.rsa_key,
            signature_method=self._signature_method
        )

        # Make the verification request, getting back an access token
        headers = {'User-Agent': self.user_agent}
        params = {'oauth_session_handle': self.oauth_session_handle}
        response = requests.post(url=self.base_url + ACCESS_TOKEN_URL,
                params=params, headers=headers, auth=oauth)
        self._process_oauth_response(response)
1033963
public function create()
    {
        // @codeCoverageIgnoreStart
        if (!empty($this->ch)) {
            curl_close($this->ch);
        }
        // @codeCoverageIgnoreEnd

        // Instantiate cURL object
        $this->ch = curl_init();

        // Apply authentication headers
        $this->authenticate();
    }
1124723
def signup_handler(remote, *args, **kwargs):
    
    # User already authenticated so move on
    if current_user.is_authenticated:
        return redirect('/')

    # Retrieve token from session
    oauth_token = token_getter(remote)
    if not oauth_token:
        return redirect('/')

    session_prefix = token_session_key(remote.name)

    # Test to see if this is coming from on authorized request
    if not session.get(session_prefix + '_autoregister', False):
        return redirect(url_for('.login', remote_app=remote.name))

    form = create_registrationform(request.form)

    if form.validate_on_submit():
        account_info = session.get(session_prefix + '_account_info')
        response = session.get(session_prefix + '_response')

        # Register user
        user = oauth_register(form)

        if user is None:
            raise OAuthError('Could not create user.', remote)

        # Remove session key
        session.pop(session_prefix + '_autoregister', None)

        # Link account and set session data
        token = token_setter(remote, oauth_token[0], secret=oauth_token[1],
                             user=user)
        handlers = current_oauthclient.signup_handlers[remote.name]

        if token is None:
            raise OAuthError('Could not create token for user.', remote)

        if not token.remote_account.extra_data:
            account_setup = handlers['setup'](token, response)
            account_setup_received.send(
                remote, token=token, response=response,
                account_setup=account_setup
            )
            # Registration has been finished
            db.session.commit()
            account_setup_committed.send(remote, token=token)
        else:
            # Registration has been finished
            db.session.commit()

        # Authenticate the user
        if not oauth_authenticate(remote.consumer_key, user,
                                  require_existing_link=False):
            # Redirect the user after registration (which doesn't include the
            # activation), waiting for user to confirm his email.
            return redirect(url_for('security.login'))

        # Remove account info from session
        session.pop(session_prefix + '_account_info', None)
        session.pop(session_prefix + '_response', None)

        # Redirect to next
        next_url = get_session_next_url(remote.name)
        if next_url:
            return redirect(next_url)
        else:
            return redirect('/')

    # Pre-fill form
    account_info = session.get(session_prefix + '_account_info')
    if not form.is_submitted():
        form = fill_form(form, account_info['user'])

    return render_template(
        current_app.config['OAUTHCLIENT_SIGNUP_TEMPLATE'],
        form=form,
        remote=remote,
        app_title=current_app.config['OAUTHCLIENT_REMOTE_APPS'][
            remote.name].get('title', ''),
        app_description=current_app.config['OAUTHCLIENT_REMOTE_APPS'][
            remote.name].get('description', ''),
        app_icon=current_app.config['OAUTHCLIENT_REMOTE_APPS'][
            remote.name].get('icon', None),
    )
166743
@RequirePOST
    public void doCreateFirstAccount(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
        if(hasSomeUser()) {
            rsp.sendError(SC_UNAUTHORIZED,"First user was already created");
            return;
        }
        User u = createAccount(req, rsp, false, "firstUser.jelly");
        if (u!=null) {
            tryToMakeAdmin(u);
            loginAndTakeBack(req, rsp, u);
        }
    }
134460
def create_session(cls, session_id, user_id):
        
        count = SessionModel.count(user_id)
        if count < current_app.config['AUTH']['MAX_SESSIONS']:
            cls.__save_session(session_id, user_id)
            return
        elif count >= current_app.config['AUTH']['MAX_SESSIONS']:
            earliest_session = SessionModel.where_earliest(user_id)
            earliest_session.delete()
            cls.__save_session(session_id, user_id)
            return
632407
def _make_request_with_auth_fallback(self, url, headers=None, params=None):
        
        self.log.debug("Request URL and Params: %s, %s", url, params)
        try:
            resp = requests.get(
                url,
                headers=headers,
                verify=self._ssl_verify,
                params=params,
                timeout=DEFAULT_API_REQUEST_TIMEOUT,
                proxies=self.proxy_config,
            )
            resp.raise_for_status()
        except requests.exceptions.HTTPError as e:
            self.log.debug("Error contacting openstack endpoint: %s", e)
            if resp.status_code == 401:
                self.log.info('Need to reauthenticate before next check')

                # Delete the scope, we'll populate a new one on the next run for this instance
                self.delete_current_scope()
            elif resp.status_code == 409:
                raise InstancePowerOffFailure()
            elif resp.status_code == 404:
                raise e
            else:
                raise

        return resp.json()
814843
def _create_session(self):
        
        self.driver = requests.Session(**self.driver_args)
        # Set default headers
        self.update_headers(self.current_headers)
        self.update_cookies(self.current_cookies)
        self.set_proxy(self.current_proxy)
705943
function createOAuthWrapper(oauthkey,
	oauthsecret, headers) {

	return new OAuthClient(
				'https://api.7digital.com/1.2/oauth/requesttoken',
				accessTokenUrl,
				oauthkey, oauthsecret, '1.0', null, 'HMAC-SHA1', 32, headers);
}
977784
def create(self, auth, type, desc, defer=False):
        
        return self._call('create', auth, [type, desc], defer)
834246
function authenticateClient (req, res, next) {
  Client.authenticate(req, function (err, client) {
    if (err) { return next(err) }
    req.client = client
    next()
  })
}
62595
protected function createClient()
    {
        $this->client = new OAuthServer([
            'identifier' => Configuration::get('key'),
            'secret' => Configuration::get('secret'),
            'callback_uri' => Configuration::get('callbackUrl'),
            'name' => Configuration::get('name'),
            'expiration' => Configuration::get('expiration'),
            'scope' => Configuration::get('scope'),
        ]);

        return $this;
    }
220959
def construct_auth (self):
        """"""
        if self.auth:
            return
        _user, _password = self.get_user_password()
        if _user is not None and _password is not None:
            self.auth = (_user, _password)
1166549
def _init_oauth(self, oauth_token, oauth_token_secret):
        ""
        self.oauth_token = oauth_token
        self.oauth_token_secret = oauth_token_secret

        self._oauth = OAuth1(
            self.consumer_key,
            client_secret=self.consumer_secret,
            resource_owner_key=self.oauth_token,
            resource_owner_secret=self.oauth_token_secret,
            rsa_key=self.rsa_key,
            signature_method=self._signature_method
        )