// Fetch the security token set by the client.
19404
func getSessionToken(r *http.Request) (token string) {
	token = r.Header.Get("X-Amz-Security-Token")
	if token != "" {
		return token
	}
	return r.URL.Query().Get("X-Amz-Security-Token")
}
944228
func (c *Cache) GetToken(token string) (services.ProvisionToken, error) {
	return c.provisionerCache.GetToken(token)
}
143103
func (db *Database) GetSecurity() (*Security, error) {
	url, err := buildUrl(db.dbName, "_security")
	if err != nil {
		return nil, err
	}
	var headers = make(map[string]string)
	sec := Security{}
	headers["Accept"] = "application/json"
	resp, err := db.connection.request("GET", url, nil, headers, db.auth)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	err = parseBody(resp, &sec)
	if err != nil {
		return nil, err
	}
	return &sec, err
}
60252
func getTokenFromReq(r *http.Request) (string, bool) {
	if token := r.Header.Get(consts.AuthHeaderName); token != "" {
		return token, false
	}
	if headers, ok := r.Header["Authorization"]; ok {
		// Reference for Authorization header format: https://tools.ietf.org/html/rfc7236#section-3

		// If string does not start by 'Bearer ', it is not one we would use,
		// but might be used by plugins
		for _, v := range headers {
			if !strings.HasPrefix(v, "Bearer ") {
				continue
			}
			return strings.TrimSpace(v[7:]), true
		}
	}
	return "", false
}
1316287
func (a *authenticator) getTokenFor(credentials *credentials) (string, int, error) {
	name, errCode, err := a.validateCredentials(credentials)
	if err != nil {
		return "", errCode, err
	}
	claims := jwt.StandardClaims{
		Audience:  name,
		ExpiresAt: a.expTime.Nanoseconds(),
	}
	token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
	tokenString, err := token.SignedString([]byte(signature))
	if err != nil {
		return "", http.StatusInternalServerError, fmt.Errorf("500 internal server error: failed to sign token: %v", err)
	}
	a.userDb.SetLoginTime(name)
	a.log.Debugf("user %s was logged in", name)

	return tokenString, 0, nil
}
823519
func getToken(md metadata.MD) string {
	// check the "token" metadata
	tokens, ok := md[apiclient.MetaDataTokenKey]
	if ok && len(tokens) > 0 {
		return tokens[0]
	}
	// check the HTTP cookie
	for _, cookieToken := range md["grpcgateway-cookie"] {
		header := http.Header{}
		header.Add("Cookie", cookieToken)
		request := http.Request{Header: header}
		token, err := request.Cookie(common.AuthCookieName)
		if err == nil {
			return token.Value
		}
	}
	return ""
}
221355
func (a *Authorization) GetToken() string {
	if a == nil || a.Token == nil {
		return ""
	}
	return *a.Token
}
1106310
func (s *ProvisioningService) GetTokens(opts ...services.MarshalOption) ([]services.ProvisionToken, error) {
	startKey := backend.Key(tokensPrefix)
	result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	tokens := make([]services.ProvisionToken, len(result.Items))
	for i, item := range result.Items {
		t, err := services.UnmarshalProvisionToken(item.Value,
			services.AddOptions(opts, services.SkipValidation(),
				services.WithResourceID(item.ID), services.WithExpires(item.Expires))...)
		if err != nil {
			return nil, trace.Wrap(err)
		}
		tokens[i] = t
	}
	return tokens, nil
}
285839
func (s *ClusterPairServer) GetToken(
	ctx context.Context,
	req *api.SdkClusterPairGetTokenRequest,
) (*api.SdkClusterPairGetTokenResponse, error) {
	if s.cluster() == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	// Check if admin user - only system.admin can get cluster pair tokens
	if userInfo, ok := auth.NewUserInfoFromContext(ctx); ok {
		o := api.Ownership{}
		if !o.IsAdminByUser(userInfo) {
			return nil, status.Error(codes.Unauthenticated, "Must be system admin to get pair token")
		}
	}

	resp, err := s.cluster().GetPairToken(false)
	if err != nil {
		return nil, status.Errorf(codes.Internal, "Cannot generate token: %v", err)
	}
	return &api.SdkClusterPairGetTokenResponse{
		Result: resp,
	}, nil
}
1361428
func (s *APIServer) getSignupTokenData(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) {
	token := p.ByName("token")

	user, otpQRCode, err := auth.GetSignupTokenData(token)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	return &getSignupTokenDataResponse{
		User:  user,
		QRImg: otpQRCode,
	}, nil
}
904662
func (c *UserConfig) GetToken() (string, string) {
	if c.AccessTokenKey != "" {
		return c.AccessTokenKey, c.AccessTokenSecret
	}
	if c.RequestTokenKey != "" {
		return c.RequestTokenKey, c.RequestTokenSecret
	}
	return "", ""
}
1116016
func (api Api) GetToken() (token string, err error) {
	defer func() { appendCaller(err, "lastfm.GetToken") }()

	var result AuthGetToken
	if err = callGet("auth.gettoken", api.params, nil, &result, P{}); err != nil {
		return
	}
	token = result.Token
	return
}
674101
func (a *Core) GetKeyAuthorization(token string) (string, error) {
	return a.jws.GetKeyAuthorization(token)
}
155140
func GetToken(r *http.Request) (string, error) {
	header := r.Header.Get("Authorization")
	if header == "" {
		return "", ErrAuthHeaderMissing
	}
	if !strings.HasPrefix(header, tokenScheme) {
		return "", ErrAuthBadScheme
	}
	return header[len(tokenScheme):], nil
}
867149
func GetOAuthToken(client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) {
	return GetOAuthTokenContext(context.Background(), client, clientID, clientSecret, code, redirectURI)
}
432081
func (oauther *OAuther) ObtainToken() (err error) {
	oauther.codeChannel = make(chan string)
	oauther.errorChannel = make(chan error)

	oauther.runServerIfNecessary()

	transport := oauther.Transport()

	// Get an authorization code from the data provider.
	// ("Please ask the user if I can access this resource.")
	authCodeUrl, _ := url.QueryUnescape(oauther.config.AuthCodeURL(""))
	webbrowser.Open(authCodeUrl)

	select {
	case authCode := <-oauther.codeChannel:
		// Exchange the authorization code for an access token.
		// ("Here's the code you gave the user, now give me a token!")
		oauther.Token, err = transport.Exchange(authCode)
		return
	case err = <-oauther.errorChannel:
		return
	}
}
1125231
func (c ClientCookies) GetToken(r *http.Request) string {
	cookie, err := r.Cookie(c.Name)
	if err != nil {
		return ""
	}
	return cookie.Value
}