# How do I get Quota working in Microgateway?

**URL:** <https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398>\
**Category:** Apigee\
**Tags:** api-runtime\
**Created:** [December 24, 2015, 3:21pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398 "2015-12-24T15:21:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [December 24, 2015, 3:21pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398/1 "2015-12-24T15:21:42Z")

</div>

I have configured the Quota plugin and restarted the gateway. When I start things up I see the Quota information downloaded from Edge product (10 per minute), but the fault doesn’t fire. I have not configured any settings in the config file other than to use the quota plugin as per instructions. I’ve tried the API call using both Bearer and API Key. The Spike arrest policy works OK.

Related thread: [Getting past “verify” step.](https://community.apigee.com/questions/14870/how-do-i-get-past-the-verify-step-when-configuring.html)

Suggestions?

---

<div class="post-metadata">

**Author:** ![willwitman](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/willwitman/32/212_2.png) [@willwitman](https://discuss.google.dev/u/willwitman)\
**Post date:** [December 24, 2015, 4:27pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398/2 "2015-12-24T16:27:20Z")

</div>

Hi Kurt,

I just tried myself, and the quota worked. You’ve probably done these steps, but here’s what I did:

1. Set up EM according to the [Setup and Configure instructions](http://docs.apigee.com/api-services/content/edge-microgateway-tutorial).

2. In the Product I created for my edgemicro\_\* proxy, I set the Quota to 5 calls per minute.

3. Added quota to the sequence in agent/config/default.yaml:

```auto
sequence:
   - oauth
   - quota

```

1. Restarted the agent and Edge Micro.

2. Called the API 5 times in quick succession and got the fault:

```auto
curl "http://localhost:8000/em-weather-111/forecastrss?w=12797282" -H "x-api-key: Arv0WtUiZ3SXGrsvcsJtYf3lrzKQJIAG"
{"message":"exceeded quota","status":403}

```

Does this help?

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [December 24, 2015, 6:23pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398/3 "2015-12-24T18:23:25Z")

</div>

As soon as I saw your sequence, I figured oauth had to be before quota, makes sense now that I think about it.

Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [December 28, 2015, 3:53pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398/4 "2015-12-28T15:53:17Z")

</div>

Ah, but I see this in the docs at: ([http://docs.apigee.com/microgateway/content/using-plugins#Using](http://docs.apigee.com/microgateway/content/using-plugins#Using) the quota plugin)[http://docs.apigee.com/microgateway/content/using-plugins#Using](http://docs.apigee.com/microgateway/content/using-plugins#Using) the quota plugin

1. Add the quota plugin to the sequence element. It’s a good idea to place quota first in the sequence list. That way, no additional processing will occur if the quota is exceeded.

---

<div class="post-metadata">

**Author:** ![willwitman](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/willwitman/32/212_2.png) [@willwitman](https://discuss.google.dev/u/willwitman)\
**Post date:** [December 28, 2015, 7:06pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398/5 "2015-12-28T19:06:03Z")

</div>

[@kurtkanaskie](https://community.apigee.com/users/2020/kurtkanaskie-1.html) Thanks for catching that – I think it is a doc bug – I’ll investigate and make the necessary corrections and update here when I’m done.

---

<div class="post-metadata">

**Author:** ![willwitman](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/willwitman/32/212_2.png) [@willwitman](https://discuss.google.dev/u/willwitman)\
**Post date:** [December 28, 2015, 9:13pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398/6 "2015-12-28T21:13:33Z")

</div>

[@kurtkanaskie](https://community.apigee.com/questions/14983/how-do-i-get-quota-working-in-microgateway.html#) Thanks again. The doc has been fixed to make it clear that to use the quota plugin, you must enable token or key authentication using the oauth plugin, and the oauth plugin must precede the quota plugin in the sequence, like this:

```auto
sequence:
   - oauth
   - quota

```

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [January 27, 2016, 1:52pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398/7 "2016-01-27T13:52:01Z")

</div>

How can I use it without “Product” ? I switched off “Authorization” by [advice](https://community.apigee.com/questions/15750/api-uses-own-authorization-how-can-i-use-my-api-th.html#answer-16166)

default.yaml

…

plugins: dir: ../plugins sequence: - analytics - quota

headers: x-forwarded-for: true x-forwarded-host: true x-request-id: true x-response-time: true via: true oauth: allowNoAuthorization: true allowInvalidAuthorization: true

…

Added “quota” plugin, added “Quota 1 request every 1 minute” to product and I think that “quota” doesn’t work. I can call my API, more than 1 request every 1 minute.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [January 27, 2016, 5:25pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398/8 "2016-01-27T17:25:29Z")

</div>

You can not use it without Product. If you want to have something custom then you would have to write your plugin.

Also pls keep in mind that Quota is an approximate quota since you don’t wan to synch with Edge for every API call.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [February 5, 2016, 2:17pm UTC](https://discuss.google.dev/t/how-do-i-get-quota-working-in-microgateway/16398/9 "2016-02-05T14:17:11Z")

</div>

Thank you for your answer. Regarding micro gateway, oauth, quota & [my question](https://community.apigee.com/questions/15750/api-uses-own-authorization-how-can-i-use-my-api-th.html#answer-16795).

As I understood, I can create “product” for each customer for authorization and can use quota (rights) for a each “product”. Or a one “product” for all customers. Right?

After that I can get statistic information for a different “products”. Right?

Can I use “product” and my authorization at the same time?
