Returns a jwt token signed by the app secret
@param {String} id - Id used to sign a token
@return {String}
16374
function signToken(id, role) {
  return jwt.sign({_id: id, role: role}, config.secrets.session, {expiresInMinutes: 60 * 5});
}
841838
@GET
    @Path("{id}")
    public EmoApiKey getApiKey(@PathParam("id") String id, @Authenticated Subject subject) {
        return _uac.getApiKey(subject, id);
    }
430463
def token(self, id, **kwargs):
        
        data = self.get('tokens', id, **kwargs)
        return data
238175
public Note get(long id)
	{
		SingleElementHandler<Note> noteHandler = new SingleElementHandler<>();
		try
		{
			osm.makeAuthenticatedRequest(NOTES + "/" + id, null, new NotesParser(noteHandler));
		}
		catch (OsmNotFoundException e)
		{
			return null;
		}
		return noteHandler.get();
	}
561760
def client_id_from_id_token(id_token):
    
    payload = JWT().unpack(id_token).payload()
    aud = payload.get('aud', None)
    if aud is None:
        return None
    if isinstance(aud, list):
        return aud[0]
    return aud
684896
def _client(self, id, secret):
        """"""
        url = self.api_url + self.auth_token_url
        auth_string = '%s:%s' % (id, secret)
        authorization = base64.b64encode(auth_string.encode()).decode()
        headers = {
            'Authorization': "Basic " + authorization,
            'Content-Type': "application/x-www-form-urlencoded"
        }
        params = {
            'grant_type': 'client_credentials',
            'response_type': 'token'
        }
        return self.session.post(url, params=params, headers=headers)
339632
public function tokenById($id)
    {
        if ($user = $this->provider->retrieveById($id)) {
            return $this->jwT->fromUser($user);
        }
    }
858558
public function getSignatureRequest($id)
    {
        $response = $this->rest->get(
            static::SIGNATURE_REQUEST_PATH . '/' . $id
        );

        $this->checkResponse($response);

        return new SignatureRequest($response);
    }
1051772
def get_key(self, id):
        
        assert isinstance(id, (int, long)), id
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            "/user/keys/" + str(id)
        )
        return github.UserKey.UserKey(self._requester, headers, data, completed=True)
313800
function getRequestId(req) {
  const id = uuid.v1();
  req.id = id;
  return {
    req_id: id,
  };
}
154906
function addJwtHandling(secrets, app) {

  if (!secrets.authTokenSecret) {
    log.error(
      'Cannot setup token authentication because token secret is not configured.'
    );
    return;
  }

  app.use(expressJwt({
    secret: secrets.authTokenSecret
  }));

  app.use(function (req, res, next) {

    if (req.user && req.user.data) {

      req.user.isAuthenticated = true;
      req.user.meta = req.user.meta || {};
    }
    next();
  });
  app.use(function (err, req, res, next) {
    if (err.name === 'UnauthorizedError') {
      if (err.code === 'credentials_required') {
        // If the caller did not provide credentials, we'll just consider this
        // an unauthenticated request.
        next();
      } else {
        res.status(401).send('Invalid token: ' + err.message);
      }
    }
  });
}
201376
public byte[] sign(byte[] data, byte[] id) {
		lock.lock();
		final SM2Signer signer = getSigner();
		try {
			CipherParameters param = new ParametersWithRandom(getCipherParameters(KeyType.PrivateKey));
			if (id != null) {
				param = new ParametersWithID(param, id);
			}
			signer.init(true, param);
			signer.update(data, 0, data.length);
			return signer.generateSignature();
		} catch (Exception e) {
			throw new CryptoException(e);
		} finally {
			lock.unlock();
		}
	}
659383
def user_get_session_token(self, app_id=None, email=None, password=None,
                               ekey=None, fb_access_token=None,
                               tw_oauth_token=None,
                               tw_oauth_token_secret=None, api_key=None):
        

        if app_id is None:
            raise ValueError("app_id must be defined")

        params = QueryParams({
            'application_id': str(app_id),
            'token_version': 2,
            'response_format': 'json'
        })

        if fb_access_token:
            params['fb_access_token'] = fb_access_token
            signature_keys = ['fb_access_token']
        elif tw_oauth_token and tw_oauth_token_secret:
            params['tw_oauth_token'] = tw_oauth_token
            params['tw_oauth_token_secret'] = tw_oauth_token_secret
            signature_keys = ['tw_oauth_token',
                              'tw_oauth_token_secret']
        elif (email or ekey) and password:
            signature_keys = []
            if email:
                signature_keys.append('email')
                params['email'] = email

            if ekey:
                signature_keys.append('ekey')
                params['ekey'] = ekey

            params['password'] = password
            signature_keys.append('password')
        else:
            raise ValueError("Credentials not provided")

        signature_keys.append('application_id')

        signature = hashlib.sha1()
        for key in signature_keys:
            signature.update(str(params[key]).encode('ascii'))

        # Note: If the app uses a callback URL to provide its API key,
        # or if it does not have the "Require Secret Key" option checked,
        # then the API key may be omitted from the signature
        if api_key:
            signature.update(api_key.encode('ascii'))

        query = urlencode(params)
        query += '&signature=' + signature.hexdigest()

        return self.request('user/get_session_token', params=query)
397547
function (id_token) {
    var jws = new KJUR.jws.JWS();
    jws.parseJWS(id_token);
    return [jws.parsedJWS.headS, jws.parsedJWS.payloadS, jws.parsedJWS.si];
  }
945495
function( id, callback ) {
    var self = this
    return this.client._clientRequest({
      url: '/alerts/rest/v1/json/get/' + id,
    }, function( error, data ) {
      callback.call( self.client, error, data )
    })
  }
563736
public static JWT verify(String jwt, String secret) {
    return verify(jwt, secret == null ? null : secret.getBytes(StandardCharsets.UTF_8));
  }
733863
function signTransaction (trs, secret) {
	var keys = crypto.getKeys(secret);
	var signature = crypto.multiSign(trs, keys);

	return {
		transaction: trs.id,
		signature: signature
	};
}