// SimpleFSGetHTTPAddressAndToken returns a random token to be used for the
// local KBFS http server.
762149
func (k *SimpleFS) SimpleFSGetHTTPAddressAndToken(ctx context.Context) (
	resp keybase1.SimpleFSGetHTTPAddressAndTokenResponse, err error) {
	if k.localHTTPServer == nil {
		return resp, errors.New("HTTP server is disabled")
	}
	if resp.Token, err = k.localHTTPServer.NewToken(); err != nil {
		return keybase1.SimpleFSGetHTTPAddressAndTokenResponse{}, err
	}
	if resp.Address, err = k.localHTTPServer.Address(); err != nil {
		return keybase1.SimpleFSGetHTTPAddressAndTokenResponse{}, err
	}

	return resp, nil
}
437454
func NewToken(token, tokenSecret string) *Token {
	return &Token{
		Token:       token,
		TokenSecret: tokenSecret,
	}
}
1100584
func (s *AuthServer) rotateAndFetchSignupToken(token string) (*services.SignupToken, error) {
	var err error

	// Fetch original signup token.
	st, err := s.GetSignupToken(token)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	// Generate and set new OTP code for user in *services.SignupToken.
	accountName := st.User.V2().GetName() + "@" + s.AuthServiceName
	st.OTPKey, st.OTPQRCode, err = s.initializeTOTP(accountName)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	// Upsert token into backend.
	err = s.UpsertSignupToken(token, *st, st.Expires.Sub(s.clock.Now()))
	if err != nil {
		return nil, trace.Wrap(err)
	}

	return st, nil
}
68675
func (s *HTTPScaffold) InsecureAddress() string {
	if s.insecureListener == nil {
		return ""
	}
	return s.insecureListener.Addr().String()
}
54156
func (a *Authorization) GetHashedToken() string {
	if a == nil || a.HashedToken == nil {
		return ""
	}
	return *a.HashedToken
}
527086
func (c *Config) ExchangeAppKeyForToken(appID, accessKey string) (*oauth2.Token, error) {
	// application Access Token
	config := c.getKeyConfig()

	token, err := getTokenFromCache(c.cache, appID, accessKey)
	if err != nil {
		return nil, err
	}

	if token != nil {
		return token, nil
	}

	token, err = config.PasswordCredentialsToken(c.getContext(), appID, accessKey)
	if err != nil {
		return nil, fromError(err)
	}

	// ignore errors when saving to cache
	_ = saveTokenToCache(c.cache, appID, accessKey, token)

	return token, nil
}
764756
func (s *HTTPScaffold) SecureAddress() string {
	if s.secureListener == nil {
		return ""
	}
	return s.secureListener.Addr().String()
}
872148
func (s *Store) ACLTokenGetBySecret(ws memdb.WatchSet, secret string) (uint64, *structs.ACLToken, error) {
	return s.aclTokenGet(ws, secret, "id")
}
312870
func MakeGetAddressesEndpoint(s Service) endpoint.Endpoint {
	return func(ctx context.Context, request interface{}) (response interface{}, err error) {
		req := request.(getAddressesRequest)
		a, e := s.GetAddresses(ctx, req.ProfileID)
		return getAddressesResponse{Addresses: a, Err: e}, nil
	}
}
236810
func (c *Client) GetSignupTokenData(token string) (user string, otpQRCode []byte, e error) {
	out, err := c.Get(c.Endpoint("signuptokens", token), url.Values{})
	if err != nil {
		return "", nil, err
	}

	var tokenData getSignupTokenDataResponse
	if err := json.Unmarshal(out.Bytes(), &tokenData); err != nil {
		return "", nil, err
	}

	return tokenData.User, tokenData.QRImg, nil
}
1132479
func (p *ecrTokenGetter) GetAuthorizationToken(input *ecr.GetAuthorizationTokenInput) (*ecr.GetAuthorizationTokenOutput, error) {
	return p.svc.GetAuthorizationToken(input)
}
580056
func (c *Client) GetRawChangeAddress(account string) (btcutil.Address, error) {
	return c.GetRawChangeAddressAsync(account).Receive()
}
628160
func (s *OauthService) ExchangeAuthorizationForToken(authorization *ExchangeAuthorizationRequest) (*AccessToken, error) {
	path := versioned("/oauth/access_token")

	req, err := s.client.NewRequest("POST", path, authorization)
	if err != nil {
		return nil, err
	}

	resp, err := s.client.httpClient.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		errorResponse := &ExchangeAuthorizationError{}
		errorResponse.HttpResponse = resp
		json.NewDecoder(resp.Body).Decode(errorResponse)
		return nil, errorResponse
	}

	accessToken := &AccessToken{}
	err = json.NewDecoder(resp.Body).Decode(accessToken)

	return accessToken, err
}
1317411
func (mw *GinJWTMiddleware) ParseTokenString(token string) (*jwt.Token, error) {
	return jwt.Parse(token, func(t *jwt.Token) (interface{}, error) {
		if jwt.GetSigningMethod(mw.SigningAlgorithm) != t.Method {
			return nil, ErrInvalidSigningAlgorithm
		}
		if mw.usingPublicKeyAlgo() {
			return mw.pubKey, nil
		}

		return mw.Key, nil
	})
}
532450
func (p *parser) parseImpliedToken(t TokenType, dataAtom a.Atom, data string) {
	realToken, selfClosing := p.tok, p.hasSelfClosingToken
	p.tok = Token{
		Type:     t,
		DataAtom: dataAtom,
		Data:     data,
	}
	p.hasSelfClosingToken = false
	p.parseCurrentToken()
	p.tok, p.hasSelfClosingToken = realToken, selfClosing
}
430326
func parseToken(s string) (string, string, error) {
	split := tokenRegexp.FindStringSubmatch(s)
	if len(split) != 3 {
		return "", "", fmt.Errorf("token [%q] was not of form [%q]", s, tokenRegexpString)
	}
	return split[1], split[2], nil
}
787777
func GetAPIServerProbeAddress(endpoint *kubeadmapi.APIEndpoint) string {
	// In the case of a self-hosted deployment, the initial host on which kubeadm --init is run,
	// will generate a DaemonSet with a nodeSelector such that all nodes with the label
	// node-role.kubernetes.io/master='' will have the API server deployed to it. Since the init
	// is run only once on an initial host, the API advertise address will be invalid for any
	// future hosts that do not have the same address. Furthermore, since liveness and readiness
	// probes do not support the Downward API we cannot dynamically set the advertise address to
	// the node's IP. The only option then is to use localhost.
	if endpoint != nil && endpoint.AdvertiseAddress != "" {
		return endpoint.AdvertiseAddress
	}

	return "127.0.0.1"
}