// GetGatewayToken gets the gateway token
779659
func (a *Account) GetGatewayToken(gatewayID string) (*oauth2.Token, error) {
	token := new(tokenRes)
	err := a.get(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s/token", gatewayID), token)
	if err != nil {
		return nil, err
	}

	return token.Token(), nil
}
386048
func GetRequestToken(client *FlickrClient) (*RequestToken, error) {
	client.EndpointUrl = REQUEST_TOKEN_URL
	client.SetOAuthDefaults()
	client.Args.Set("oauth_consumer_key", client.ApiKey)
	client.Args.Set("oauth_callback", "oob")

	// we don't have token secret at this stage, pass an empty string
	client.Sign("")

	res, err := client.HTTPClient.Get(client.GetUrl())
	if err != nil {
		return nil, err
	}

	defer res.Body.Close()
	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		return nil, err
	}

	return ParseRequestToken(string(body))
}
534430
func (a *Account) ListGateways() (gateways []Gateway, err error) {
	err = a.get(a.auth, "/api/v2/gateways", &gateways)
	return gateways, err
}
396193
func (a *Account) RegisterGateway(gatewayID string, frequencyPlan string, opts GatewaySettings) (gateway Gateway, err error) {
	if gatewayID == "" {
		return gateway, errors.New("Cannot create gateway: no ID given")
	}

	if frequencyPlan == "" {
		return gateway, errors.New("Cannot create gateway: no frequency plan given")
	}

	req := registerGatewayReq{
		ID:              gatewayID,
		FrequencyPlan:   frequencyPlan,
		AntennaLocation: opts.AntennaLocation,
		Attributes:      opts.Attributes,
		Router:          opts.Router,
	}

	err = a.post(a.auth, "/api/v2/gateways", req, &gateway)
	return gateway, err
}
367717
func (s *CreateCachediSCSIVolumeInput) SetGatewayARN(v string) *CreateCachediSCSIVolumeInput {
	s.GatewayARN = &v
	return s
}
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
}
64023
func (a *Account) FindGateway(gatewayID string) (gateway Gateway, err error) {
	var res gatewayRes
	err = a.get(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s", gatewayID), &res)
	if err != nil {
		return gateway, err
	}
	return res.ToGateway(), err
}
1209585
func (s *Server) removeGatewayURL(urlStr string) {
	s.gateway.Lock()
	delete(s.gateway.URLs, urlStr)
	s.gateway.Unlock()
}
674101
func (a *Core) GetKeyAuthorization(token string) (string, error) {
	return a.jws.GetKeyAuthorization(token)
}
1039717
func GetGatewayProfile(db sqlx.Queryer, id uuid.UUID) (GatewayProfile, error) {
	var c GatewayProfile
	err := db.QueryRowx(`
		select
			gateway_profile_id,
			created_at,
			updated_at,
			channels
		from gateway_profile
		where
			gateway_profile_id = $1`,
		id,
	).Scan(
		&c.ID,
		&c.CreatedAt,
		&c.UpdatedAt,
		pq.Array(&c.Channels),
	)
	if err != nil {
		return c, handlePSQLError(err, "select error")
	}

	rows, err := db.Query(`
		select
			modulation,
			frequency,
			bandwidth,
			bitrate,
			spreading_factors
		from gateway_profile_extra_channel
		where
			gateway_profile_id = $1
		order by id`,
		id,
	)
	if err != nil {
		return c, handlePSQLError(err, "select error")
	}
	defer rows.Close()

	for rows.Next() {
		var ec ExtraChannel
		err := rows.Scan(
			&ec.Modulation,
			&ec.Frequency,
			&ec.Bandwidth,
			&ec.Bitrate,
			pq.Array(&ec.SpreadingFactors),
		)
		if err != nil {
			return c, handlePSQLError(err, "select error")
		}
		c.ExtraChannels = append(c.ExtraChannels, ec)
	}

	return c, nil
}
159973
func (t *Template) GetAllAWSEC2TransitGatewayResources() map[string]*resources.AWSEC2TransitGateway {
	results := map[string]*resources.AWSEC2TransitGateway{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSEC2TransitGateway:
			results[name] = resource
		}
	}
	return results
}
377373
func (a *API) GetToken(token int) (*Token, error) {
	dst := new(Token)
	url := a.BuildURL("/v2/agent/token/%d", token)
	err := a.Get(url, Params{}, dst)
	return dst, err
}
595554
func (c *UserConfig) GetRequestToken(service *Service, client *http.Client) error {
	data := url.Values{}
	if service.ClientConfig.CallbackURL != "" {
		data.Set("oauth_callback", service.ClientConfig.CallbackURL)
	}
	body := strings.NewReader(data.Encode())
	request, err := http.NewRequest("POST", service.RequestURL, body)
	if err != nil {
		return err
	}
	request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	response, err := c.send(request, service, client)
	if err != nil {
		return err
	}
	err = c.parseRequestToken(response)
	return err
}
547628
func (m *manager) GetToken(opts *auth.Options) (string, error) {
	signature, err := auth.NewSignatureSharedSecret(m.config.SharedSecret)
	if err != nil {
		return "", err
	}

	return auth.Token(m.claims, signature, opts)
}
1212521
func (s *Server) reconnectGateway(cfg *gatewayCfg) {
	defer s.grWG.Done()

	delay := time.Duration(rand.Intn(100)) * time.Millisecond
	if !cfg.isImplicit() {
		delay += gatewayReconnectDelay
	}
	select {
	case <-time.After(delay):
	case <-s.quitCh:
		return
	}
	s.solicitGateway(cfg)
}
191096
func (s *Server) getOutboundGatewayConnection(name string) *client {
	s.gateway.RLock()
	gwc := s.gateway.out[name]
	s.gateway.RUnlock()
	return gwc
}
1023848
func (s *Server) getOutboundGatewayConnections(a *[]*client) {
	s.gateway.RLock()
	for i := 0; i < len(s.gateway.outo); i++ {
		*a = append(*a, s.gateway.outo[i])
	}
	s.gateway.RUnlock()
}