# Authorization: Bearer {token}

**URL:** <https://discuss.dgraph.io/t/authorization-bearer-token/9133>\
**Category:** GraphQL\
**Tags:** auth, kind:enhancement, status:accepted, ticket:created\
**Created:** [July 31, 2020, 10:20am UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133 "2020-07-31T10:20:05Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![wietseva](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/wietseva/32/4237_2.png) [@wietseva](https://discuss.dgraph.io/u/wietseva)\
**Post date:** [July 31, 2020, 10:20am UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/1 "2020-07-31T10:20:05Z")

</div>

With the graphql schema Authorization Provider config.

```auto
# Dgraph.Authorization {"VerificationKey":"","Header":"","Namespace":"","Algo":"","Audience":[]}

```

How would you specify to grab the jwt token from the Authorization header?

```auto
Auhtorizaion: Bearer {token}

```

---

<div class="post-metadata">

**Author:** ![abhimanyusinghgaur](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abhimanyusinghgaur/32/2980_2.png) [@abhimanyusinghgaur](https://discuss.dgraph.io/u/abhimanyusinghgaur)\
**Post date:** [July 31, 2020, 10:25am UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/2 "2020-07-31T10:25:55Z")

</div>

You would need to specify the `Header` key as `Authorization`, like this:

```auto
# Dgraph.Authorization {"VerificationKey":"","Header":"Authorization","Namespace":"","Algo":"","Audience":[]}

```

---

<div class="post-metadata">

**Author:** ![wietseva](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/wietseva/32/4237_2.png) [@wietseva](https://discuss.dgraph.io/u/wietseva)\
**Post date:** [July 31, 2020, 10:56am UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/3 "2020-07-31T10:56:44Z")

</div>

Then you get an error that the token is invalid, because Dgraph does not strip `bearer` from the Authorization header.

```auto
{
  "errors": [
    {
      "message": "mutation failed because authorization failed because unable to parse jwt token:token is malformed: tokenstring should not contain 'bearer '"
    }
  ],
 ...
}

```

---

<div class="post-metadata">

**Author:** ![abhimanyusinghgaur](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abhimanyusinghgaur/32/2980_2.png) [@abhimanyusinghgaur](https://discuss.dgraph.io/u/abhimanyusinghgaur)\
**Post date:** [July 31, 2020, 11:06am UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/4 "2020-07-31T11:06:47Z")

</div>

Ok, at present, the header should directly contain the JWT token without the `Bearer` part.  
If you don’t want to use `Authorization` header for that purpose, because you may be using it for other places too, then you can use a custom header at present which just contains the JWT token.

We will add support for standard `Authorization` header parsing later.

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [February 25, 2021, 10:17pm UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/5 "2021-02-25T22:17:59Z")

</div>

@hardik – Can you please get this issue resolved?

---

<div class="post-metadata">

**Author:** ![matthewmcneely](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/matthewmcneely/32/4774_2.png) [@matthewmcneely](https://discuss.dgraph.io/u/matthewmcneely)\
**Post date:** [February 25, 2021, 9:14pm UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/7 "2021-02-25T21:14:20Z")

</div>

> I don’t see any issue related to Bearer token

> [@Authorization: Bearer {token}](http://discuss.hypermode.com/t/authorization-bearer-token/9133):
>
> With the graphql schema Authorization Provider config. # Dgraph.Authorization {"VerificationKey":"","Header":"","Namespace":"","Algo":"","Audience":[]} How would you specify to grab the jwt token from the Authorization header? Auhtorizaion: Bearer {token}

I have a fix in a fork for this. Just trying to get testing working in my fork before submitting a PR.

---

<div class="post-metadata">

**Author:** ![vvbalaji](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/vvbalaji/32/3091_2.png) [@vvbalaji](https://discuss.dgraph.io/u/vvbalaji)\
**Post date:** [February 25, 2021, 10:17pm UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/8 "2021-02-25T22:17:11Z")

</div>

thats great @matthewmcneely . cc: @abhimanyusinghgaur

---

<div class="post-metadata">

**Author:** ![matthewmcneely](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/matthewmcneely/32/4774_2.png) [@matthewmcneely](https://discuss.dgraph.io/u/matthewmcneely)\
**Post date:** [February 25, 2021, 10:27pm UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/9 "2021-02-25T22:27:08Z")

</div>

@vvbalaji Any chance we could video conference for 15 minutes to help me get the testing in the /t folder working? Can’t seem to get the tests to find my cluster.

Or maybe there’s an internal doc somewhere you could point me to.

In the meantime, the first change in this diff is how I fixed the Bearer issue @abhimanyusinghgaur — might be easier than me getting je\_malloc and my other build issues dealt with in order to create a PR.

> **[Comparing...](https://github.com/dgraph-io/dgraph/compare/v20.11.2...matthewmcneely:matthewmcneely/feature-auth-issues)**
>
> The high-performance database for modern applications - Comparing dgraph-io:v20.11.2...matthewmcneely:matthewmcneely/feature-auth-issues · dgraph-io/dgraph

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [February 26, 2021, 12:17am UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/10 "2021-02-26T00:17:40Z")

</div>

Perhaps the team can help you create a PR, so our TeamCity can run the tests automatically.

---

<div class="post-metadata">

**Author:** ![matthewmcneely](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/matthewmcneely/32/4774_2.png) [@matthewmcneely](https://discuss.dgraph.io/u/matthewmcneely)\
**Post date:** [February 26, 2021, 12:42am UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/11 "2021-02-26T00:42:16Z")

</div>

@mrjn Indeed, appreciate any help… there’s issues with my local builds for testing with jemalloc and tagging images that I’m stymied on (can’t find any docs save the readme in the /t folder).

Note, I’m able to build the Docker images on my machine (OSX), it’s just those native builds that seem to be failing. With the dropping of OSX and Windows native support, maybe the tests should be converted to only use Docker images.

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [February 26, 2021, 12:26pm UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/12 "2021-02-26T12:26:52Z")

</div>

@hardik : Can we add a task to simplify the builds?

---

<div class="post-metadata">

**Author:** ![abhimanyusinghgaur](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abhimanyusinghgaur/32/2980_2.png) [@abhimanyusinghgaur](https://discuss.dgraph.io/u/abhimanyusinghgaur)\
**Post date:** [February 26, 2021, 12:36pm UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/13 "2021-02-26T12:36:04Z")

</div>

Hi @matthewmcneely,

I have raised a PR for the same against the `master` branch with the required tests: [feat(GraphQL): Add support for passing OAuth Bearer token as authorization JWT (GRAPHQL-1049) by abhimanyusinghgaur · Pull Request #7490 · dgraph-io/dgraph · GitHub](https://github.com/dgraph-io/dgraph/pull/7490)

Could you please have a look and approve if it suffices the use case?

Thanks

---

<div class="post-metadata">

**Author:** ![matthewmcneely](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/matthewmcneely/32/4774_2.png) [@matthewmcneely](https://discuss.dgraph.io/u/matthewmcneely)\
**Post date:** [March 3, 2021, 6:01pm UTC](https://discuss.dgraph.io/t/authorization-bearer-token/9133/14 "2021-03-03T18:01:55Z")

</div>

@abhimanyusinghgaur Sorry for the late reply (didn’t get the expected email notification). That looks good… glad you created it as it seems there were more places to touch. Thanks for getting this in!
