Generate a token that can be used to log the customer into the storefront.
 This requires your app to have the store_v2_customers_login scope and to
 be installed in the store.
428600
def login_token(config: Bigcommerce.config)
      payload = {
        'iss' => config.client_id,
        'iat' => Time.now.to_i,
        'jti' => SecureRandom.uuid,
        'operation' => 'customer_login',
        'store_hash' => config.store_hash,
        'customer_id' => id
      }

      JWT.encode(payload, config.client_secret, 'HS256')
    end
610038
def _verify_and_add_jwt():
    
    if not app_context_has_jwt_data():
        guard = current_guard()
        token = guard.read_token_from_header()
        jwt_data = guard.extract_jwt_token(token)
        add_jwt_data_to_app_context(jwt_data)
1234619
private static function create_login_token() {
        global $SESSION;

        $state = [
            'token' => random_string(32),
            'created' => time() // Server time - not user time.
        ];

        if (!isset($SESSION->logintoken)) {
            $SESSION->logintoken = [];
        }

        // Overwrite any previous values.
        $SESSION->logintoken[self::$logintokenkey] = $state;

        return $state;
    }
492859
def create(customer, **data):
        
        if isinstance(customer, resources.Customer):
            customer = customer.id

        http_client = HttpClient()
        response, _ = http_client.post(routes.url(routes.CARD_RESOURCE, customer_id=customer), data)
        return resources.Card(**response)
516588
function login(user, callback) {
      /* jshint validthis:true */
      var cb = callback || angular.noop;
      var deferred = $q.defer();
      $cookies.customerId = user.customerId;

      $http.post('/auth/local', {
        customerId: user.customerId,
        name: user.name,
        password: user.password
      }).success(function (data) {
        $cookieStore.put('token', data.token);
        $cookieStore.remove('customerID');
        currentUser = User.get();
        deferred.resolve(data);
        return cb();
      }).error(function (err) {
        this.logout();
        deferred.reject(err);
        return cb(err);
      }.bind(this));

      return deferred.promise;
    }
794641
def _generateForTokenSecurity(self):
        
        agolToken = self._agolSecurityHandler.token
        url = self._url + "/getProxyUserToken"
        params = {"token" : self._agolSecurityHandler.token,
                  "contributorUid" : self._contributionUID}
        res = self._post(url=url, param_dict=params,
                         additional_headers={ "Referer": self._agolSecurityHandler._referer_url},
                         proxy_port=self._proxy_port,
                         proxy_url=self._proxy_url)
        return res['token']
386397
def get(self):
    """"""
    client_customer_id = self.request.get('clientCustomerId')

    template_values = {
        'back_url': '/showAccounts',
        'back_msg': 'View Accounts.',
        'ccid': client_customer_id,
        'logout_url': users.create_logout_url('/'),
        'user_nickname': users.get_current_user().nickname()
    }

    try:
      try:
        app_user = InitUser()

        # Load Client instance.
        handler = APIHandler(app_user.client_id,
                             app_user.client_secret,
                             app_user.refresh_token,
                             app_user.adwords_manager_cid,
                             app_user.developer_token)

        campaigns = handler.GetCampaigns(client_customer_id)
      except Exception, e:
        template_values['error'] = str(e)
    finally:
      # Use template to write output to the page.
      template_values['campaigns'] = campaigns
      path = os.path.join(os.path.dirname(__file__),
                          '../templates/show_campaigns.html')
      self.response.out.write(template.render(path, template_values))
147666
function init(ctx) {
  let token = ctx.cookies.get('pToken') || ctx.request.header.token
  if (token) {
    ctx.response.append('token', token)
    ctx.request.header.token = token
  }
  let userId = ctx.cookies.get('userId') || ctx.request.header.userid
  if (userId) {
    ctx.response.append('userid', userId)
    ctx.request.header.userid = userId
  }
  let accountId = ctx.cookies.get('accountId') || ctx.request.header.accountid
  if (accountId) {
    ctx.response.append('accountid', accountId)
    ctx.request.header.accountid = accountId
  }
  let companyId = ctx.cookies.get('companyId') || ctx.request.header.companyid
  if (companyId) {
    ctx.response.append('companyid', companyId)
    ctx.request.header.companyid = companyId
  }
  ctx.user = {
    companyid: companyId,
    accountid: accountId,
    userid: userId,
    language: ctx.cookies.get('language') || 'zh'
  }
}
547799
def get_token(self):
        
        self.token = self._session.fetch_token(
            token_url=CLOUD_URLS["get_token"][1],
            client_id=self._client_id,
            client_secret=self._client_secret
        )
1360509
function(options) {
      options = opts(this, options);
      options.applevel = true;

      var token = this.options.session_token;
      this.options.email = null;
      this.options.username = null;
      this.options.session_token = null;

      if (options.savelogin) {
        store('email', null, this.options.appid);
        store('username', null, this.options.appid);
        store('session_token', this.options.appid);
      }

      return new APICall({
        action: 'account/logout',
        type: 'POST',
        processResponse: APICall.basicResponse,
        headers: {
          'X-CloudMine-SessionToken': token
        },
        options: options
      });
    }
840090
def customer_permit(self, session):
        ''''''
        request = TOPRequest('taobao.increment.customer.permit')
        self.create(self.execute(request, session), fields=['app_customer',], models={'app_customer':AppCustomer})
        return self.app_customer
604185
public static function generateToken($client_id, $redirect_uri, $scope = 'public_content')
  {
    $params = array(
      'client_id'     => $client_id,
      'redirect_uri'  => $redirect_uri,
      'response_type' => 'token',
      'scope'         => $scope
    );
    header('location:https://www.instagram.com/oauth/authorize/?' . http_build_query($params));
    die;
  }
1145197
def token(self):
        
        if self._token is None or \
           datetime.datetime.now() >= self._token_expires_on:
            if self._referer_url is None:
                result = self._generateForTokenSecurity(username=self._username,
                                                    password=self._password,
                                                    tokenUrl=self._token_url)
            else:
                result = self._generateForTokenSecurity(username=self._username,
                                                        password=self._password,
                                                        tokenUrl=self._token_url,
                                                        client="referer")
            if 'error' in result:
                self._valid = False
                self._message = result
            else:
                self._valid = True
                self._message = "Token Generated"
        return self._token
730805
def fetch_access_token(self, oauth_request):
        
        version = self._get_version(oauth_request)
        consumer = self._get_consumer(oauth_request)
        try:
            verifier = self._get_verifier(oauth_request)
        except Error:
            verifier = None
        # Get the request token.
        token = self._get_token(oauth_request, 'request')
        self._check_signature(oauth_request, consumer, token)
        new_token = self.data_store.fetch_access_token(consumer, token, verifier)
        return new_token
31208
public function generateToken()
    {
        if (isset($this->token)) return;

        $this->token = base_convert(md5(uniqid(rand(), true)), 16, 36);
        setcookie($this->getCookieName(), $this->token, time() + $this->cookie_lifetime, '/');
    }
3063
def fetch_request_token(self, oauth_request):
        
        try:
            # Get the request token for authorization.
            token = self._get_token(oauth_request, 'request')
        except Error:
            # No token required for the initial token request.
            version = self._get_version(oauth_request)
            consumer = self._get_consumer(oauth_request)
            try:
                callback = self.get_callback(oauth_request)
            except Error:
                callback = None # 1.0, no callback specified.
            self._check_signature(oauth_request, consumer, None)
            # Fetch a new token.
            token = self.data_store.fetch_request_token(consumer, callback)
        return token
1010987
def acquire_token
      token_acquire_url = TOKEN_ACQUIRE_URL.dup
      token_acquire_url['{authentication_endpoint}'] = @settings.authentication_endpoint
      token_acquire_url['{tenant_id}'] = @tenant_id

      url = URI.parse(token_acquire_url)

      connection = Faraday.new(:url => url, :ssl => MsRest.ssl_options) do |builder|
        builder.adapter Faraday.default_adapter
      end

      request_body = REQUEST_BODY_PATTERN.dup
      request_body['{resource_uri}'] = ERB::Util.url_encode(@settings.token_audience)
      request_body['{client_id}'] = ERB::Util.url_encode(@client_id)
      request_body['{client_secret}'] = ERB::Util.url_encode(@client_secret)

      response = connection.get do |request|
        request.headers['content-type'] = 'application/x-www-form-urlencoded'
        request.body = request_body
      end

      fail AzureOperationError,
        'Couldn\'t login to Azure, please verify your tenant id, client id and client secret' unless response.status == 200

      response_body = JSON.load(response.body)
      @token = response_body['access_token']
      @token_expires_on = Time.at(Integer(response_body['expires_on']))
      @token_type = response_body['token_type']
    end