Register a user from a social channel (only Facebook has been tested)
345064
public function registerFacebookUserAction()
    {
        // The provider has to be set in the querystring of the request for hybridauth to work properly.
        $provider = $this->params()->fromRoute('provider');
        $this->getRequest()->getQuery()->provider = $provider;

        $this->zfcUserAuthentication()->getAuthAdapter()->resetAdapters();
        $this->zfcUserAuthentication()->getAuthService()->clearIdentity();

        $adapter = $this->zfcUserAuthentication()->getAuthAdapter();
        $adapter->prepareForAuthentication($this->getRequest());

        $this->zfcUserAuthentication()->getAuthService()->authenticate($adapter);

        $user = $this->zfcUserAuthentication()->getIdentity();

        $viewModel = new ViewModel();
        $viewModel->setVariables(array('user' => $user));

        return $viewModel;
    }
426290
def self_register_user(self, user_name, account_id, user_terms_of_use, pseudonym_unique_id, communication_channel_address=None, communication_channel_type=None, user_birthdate=None, user_locale=None, user_short_name=None, user_sortable_name=None, user_time_zone=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - account_id
        """ID"""
        path["account_id"] = account_id

        # REQUIRED - user[name]
        """The full name of the user. This name will be used by teacher for grading."""
        data["user[name]"] = user_name

        # OPTIONAL - user[short_name]
        """User's name as it will be displayed in discussions, messages, and comments."""
        if user_short_name is not None:
            data["user[short_name]"] = user_short_name

        # OPTIONAL - user[sortable_name]
        """User's name as used to sort alphabetically in lists."""
        if user_sortable_name is not None:
            data["user[sortable_name]"] = user_sortable_name

        # OPTIONAL - user[time_zone]
        """The time zone for the user. Allowed time zones are
        {http://www.iana.org/time-zones IANA time zones} or friendlier
        {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Ruby on Rails time zones}."""
        if user_time_zone is not None:
            data["user[time_zone]"] = user_time_zone

        # OPTIONAL - user[locale]
        """The user's preferred language, from the list of languages Canvas supports.
        This is in RFC-5646 format."""
        if user_locale is not None:
            data["user[locale]"] = user_locale

        # OPTIONAL - user[birthdate]
        """The user's birth date."""
        if user_birthdate is not None:
            data["user[birthdate]"] = user_birthdate

        # REQUIRED - user[terms_of_use]
        """Whether the user accepts the terms of use."""
        data["user[terms_of_use]"] = user_terms_of_use

        # REQUIRED - pseudonym[unique_id]
        """User's login ID. Must be a valid email address."""
        data["pseudonym[unique_id]"] = pseudonym_unique_id

        # OPTIONAL - communication_channel[type]
        """The communication channel type, e.g. 'email' or 'sms'."""
        if communication_channel_type is not None:
            data["communication_channel[type]"] = communication_channel_type

        # OPTIONAL - communication_channel[address]
        """The communication channel address, e.g. the user's email address."""
        if communication_channel_address is not None:
            data["communication_channel[address]"] = communication_channel_address

        self.logger.debug("POST /api/v1/accounts/{account_id}/self_registration with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("POST", "/api/v1/accounts/{account_id}/self_registration".format(**path), data=data, params=params, single_item=True)
736794
public function register()
    {
        $this->app->singleton('LinkedIn', function(){
            $linkedIn = new LinkedInLaravel(config('linkedin.api_key'), config('linkedin.api_secret'));
            $linkedIn->setHttpClient(new Client());
            $linkedIn->setHttpMessageFactory(new HttpGuzzleMessageFactory());

            return $linkedIn;
        });

        $this->app->alias('LinkedIn', 'linkedin');
    }
870850
public function authenticate(){
		$result = false;
		bimport('http.request');
		$code=BRequest::GetString('code');
		if(!isset($code)) {
			BLog::addToLog('[Social.FB] Code is empty!',LL_ERROR);
			return false;
			}
		$params = array(
			'client_id'	=> $this->clientId,
			'redirect_uri'  => $this->redirectUri,
//			'state'		=> 
			'client_secret' => $this->clientSecret,
			'code'	        => $code
			);
		parse_str($this->get('https://graph.facebook.com/oauth/access_token', $params, false), $tokenInfo);
		if(empty($tokenInfo)){
			BLog::addToLog('[Social.FB] tokenInfo is empty!',LL_ERROR);
			return false;
			}
		if(!isset($tokenInfo['access_token'])) {
			BLog::addToLog('[Social.FB] Access token is not set!',LL_ERROR);
			BLog::addToLog('[Social.FB] tokenInfo="'.var_export($tokenInfo,true).'".',LL_ERROR);
			return false;
			}
		$this->access_token=$tokenInfo['access_token'];
		$params = array('access_token' => $this->access_token,'fields' => 'id,name,email,birthday,gender');
		$userInfo = $this->get('https://graph.facebook.com/me', $params);
		if(!isset($userInfo['id'])) {
			BLog::addToLog('[Social.FB] userInfo id is not set!',LL_ERROR);
			BLog::addToLog('[Social.FB] userInfo="'.var_export($userInfo,true).'".',LL_ERROR);
			return false;
			}
		BLog::addToLog('[Social.FB] Got social info: '.var_export($userInfo,true));
		$this->userInfo = $userInfo;
		//
		if(!$this->createsession()){
			BLog::addToLog('[Social.FB] Could not create session!',LL_ERROR);
			return false;
			}
		BLog::addToLog('[Social.FB] All done!');
		return true;
		}
174408
def authenticate(&callback)
      user("me") do |user|
        self.token = user.token
        callback.call(user)
      end
    end
1103632
async def _register(self):
        
        if self.registered:
            return
        self._registration_attempts += 1

        # Don't throttle during registration, most ircds don't care for flooding during registration,
        # and it might speed it up significantly.
        self.connection.throttle = False

        # Password first.
        if self.password:
            await self.rawmsg('PASS', self.password)

        # Then nickname...
        await self.set_nickname(self._attempt_nicknames.pop(0))
        # And now for the rest of the user information.
        await self.rawmsg('USER', self.username, '0', '*', self.realname)
409361
public function register(UserInterface $user, RegisterInfoInterface $registerInfo) {
		
		$database_profile = $this->socialProfileRepository->findByUserAndProvider($user, 'UserProfile');
		if($database_profile === null) {
			$profile = $registerInfo->getProfile();
			
			$this->copyProfileToDatabase($user, $profile);
			
		}
	}
1103604
public function authenticate()
    {
        try {
            $service = $this->service;

            $session = $service->getSession();
            
            $me = (new FacebookRequest(
                $session, 'GET', '/me'
            ))->execute()->getGraphObject(GraphUser::className());
            
            $res = new OAuth2Result(
                $this->authenticationService,
                Result::SUCCESS,
                $me->getId()
            );
            $res->setUserProfile($this->createUserProfile($session, $me));
            
            //TODO
            //$res->setAccessToken($token->accessToken);
            //$res->setRefreshToken($token->refreshToken);
            //$res->setExpiresIn($token->expires);
            
            return $res;

        } catch(FacebookRequestException $ex) {
            // When Facebook returns an error
            return new Result(
                $this->authenticationService,
                Result::FAILURE_CREDENTIAL_INVALID,
                array(),
                array("Facebook request exception - " . $ex->getErrorType() . " - " . $ex->getMessage())
            );
        } catch(\Exception $ex) {
            // When validation fails or other local issues
            return new Result(
                $this->authenticationService,
                Result::FAILURE,
                array(),
                array("General exception - " . $ex->getMessage())
            );
        }
    }
168855
function createByTwitter(profile, callback) {
  if (!profile.id) {
    return callback(new Error('Profile id is undefined'));
  }

  this.findByTwitterID(profile.id, ok(callback, (user) => {
    if (user) {
      return callback(null, user);
    }

    this.create({
      username: profile.username || null,
      name: profile.displayName,
    }, ok(callback, (newUser) => {
      newUser.addProvider('twitter', profile.id, profile, ok(callback, () => {
        callback(null, newUser);
      }));
    }));
  }));
}
210732
def authorize(channel, callback)
      if is_private_channel(channel.name)
        auth_data = get_private_auth(channel)
      elsif is_presence_channel(channel.name)
        auth_data = get_presence_auth(channel)
      end
      # could both be nil if didn't require auth
      callback.call(channel, auth_data, channel.user_data)
    end
790746
def register():
    "  "
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        # create an user instance not yet stored in the database
        user = User(
            username=form.username.data,
            email=form.email.data,
            pw_hash=form.password.data)

        # Insert the record in our database and commit it
        db.session.add(user)
        db.session.commit()

        users.login(user)

        # flash will display a message to the user
        flash(_('Thanks for registering'))
        # redirect user to the 'home' method of the user module.
        return redirect(url_for('users.profile'))
    return render_template("users/register.html", form=form)
946655
public function authenticatedUserFollowsChannel($user, $channel, $options = [], $token = null)
    {
        $availableOptions = ['notifications'];

        return $this->sendRequest('PUT', 'users/'.$user.'/follows/channels/'.$channel, $this->getToken($token), $options, $availableOptions);
    }
543212
def register_view(self):
        

        safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_LOGIN_ENDPOINT)
        safe_reg_next_url = self._get_safe_next_url('reg_next', self.USER_AFTER_REGISTER_ENDPOINT)

        # Initialize form
        login_form = self.LoginFormClass()  # for login_or_register.html
        register_form = self.RegisterFormClass(request.form)  # for register.html

        # invite token used to determine validity of registeree
        invite_token = request.values.get("token")

        # require invite without a token should disallow the user from registering
        if self.USER_REQUIRE_INVITATION and not invite_token:
            flash("Registration is invite only", "error")
            return redirect(url_for('user.login'))

        user_invitation = None
        if invite_token and self.db_manager.UserInvitationClass:
            data_items = self.token_manager.verify_token(invite_token, self.USER_INVITE_EXPIRATION)
            if data_items:
                user_invitation_id = data_items[0]
                user_invitation = self.db_manager.get_user_invitation_by_id(user_invitation_id)

            if not user_invitation:
                flash("Invalid invitation token", "error")
                return redirect(url_for('user.login'))

            register_form.invite_token.data = invite_token

        if request.method != 'POST':
            login_form.next.data = register_form.next.data = safe_next_url
            login_form.reg_next.data = register_form.reg_next.data = safe_reg_next_url
            if user_invitation:
                register_form.email.data = user_invitation.email

        # Process valid POST
        if request.method == 'POST' and register_form.validate():
            user = self.db_manager.add_user()
            register_form.populate_obj(user)
            user_email = self.db_manager.add_user_email(user=user, is_primary=True)
            register_form.populate_obj(user_email)

            # Store password hash instead of password
            user.password = self.hash_password(user.password)

            # Email confirmation depends on the USER_ENABLE_CONFIRM_EMAIL setting
            request_email_confirmation = self.USER_ENABLE_CONFIRM_EMAIL
            # Users that register through an invitation, can skip this process
            # but only when they register with an email that matches their invitation.
            if user_invitation:
                if user_invitation.email.lower() == register_form.email.data.lower():
                    user_email.email_confirmed_at=datetime.utcnow()
                    request_email_confirmation = False

            self.db_manager.save_user_and_user_email(user, user_email)
            self.db_manager.commit()

            # Send 'registered' email and delete new User object if send fails
            if self.USER_SEND_REGISTERED_EMAIL:
                try:
                    # Send 'confirm email' or 'registered' email
                    self._send_registered_email(user, user_email, request_email_confirmation)
                except Exception as e:
                    # delete new User object if send  fails
                    self.db_manager.delete_object(user)
                    self.db_manager.commit()
                    raise

            # Send user_registered signal
            signals.user_registered.send(current_app._get_current_object(),
                                         user=user,
                                         user_invitation=user_invitation)

            # Redirect if USER_ENABLE_CONFIRM_EMAIL is set
            if self.USER_ENABLE_CONFIRM_EMAIL and request_email_confirmation:
                safe_reg_next_url = self.make_safe_url(register_form.reg_next.data)
                return redirect(safe_reg_next_url)

            # Auto-login after register or redirect to login page
            if 'reg_next' in request.args:
                safe_reg_next_url = self.make_safe_url(register_form.reg_next.data)
            else:
                safe_reg_next_url = self._endpoint_url(self.USER_AFTER_CONFIRM_ENDPOINT)
            if self.USER_AUTO_LOGIN_AFTER_REGISTER:
                return self._do_login_user(user, safe_reg_next_url)  # auto-login
            else:
                return redirect(url_for('user.login') + '?next=' + quote(safe_reg_next_url))  # redirect to login page

        # Render form
        self.prepare_domain_translations()
        return render_template(self.USER_REGISTER_TEMPLATE,
                      form=register_form,
                      login_form=login_form,
                      register_form=register_form)
729102
public function register()
	{
        $configPath = __DIR__.'/../../config/social-share.php';
        $this->mergeConfigFrom($configPath, 'social-share');

		$this->app->singleton('share', function($app)
		{
			return new Share($app);
		});
	}
835350
function (req, res, next) {
    var graphApiUrl = 'https://graph.facebook.com/me';
    var accessToken = req.accessToken;

    request.get({ url: graphApiUrl, qs: accessToken, json: true }, function(err, response, profile) {
      if (response.statusCode !== 200) {
        res.status(500).send({ message: profile.error.message });
        return;
      }
      req.profile = profile;
      next();
    });
  }
531287
def login_with(cls, platform, third_party_auth_data):
        '''
        
        '''
        user = User()
        return user.link_with(platform, third_party_auth_data)
1210222
async def get_user(self, user_id, page_id):
        

        access_token = self._access_token(page_id=page_id)

        params = {
            'fields': 'first_name,last_name,profile_pic,locale,timezone'
                      ',gender',
            'access_token': access_token,
        }

        url = GRAPH_ENDPOINT.format(user_id)

        get = self.session.get(url, params=params)
        async with get as r:
            await self._handle_fb_response(r)
            return await r.json()