# Can't use access token issued by authorized\_code grant for another client

**URL:** <https://forum.keycloak.org/t/cant-use-access-token-issued-by-authorized-code-grant-for-another-client/402>\
**Category:** Getting advice\
**Created:** [November 13, 2019, 10:34am UTC](https://forum.keycloak.org/t/cant-use-access-token-issued-by-authorized-code-grant-for-another-client/402 "2019-11-13T10:34:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arw357](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/arw357/32/9384_2.png) [@arw357](https://forum.keycloak.org/u/arw357)\
**Post date:** [November 13, 2019, 10:34am UTC](https://forum.keycloak.org/t/cant-use-access-token-issued-by-authorized-code-grant-for-another-client/402/1 "2019-11-13T10:34:34Z")

</div>

Hello, and thank you for reading this.  
My setup is like this - I have a client setup in keycloak that is used by the UI for authentication. No authorization. This client is public.  
I have another client setup as the resource server (authorization enabled ) in keycloak. This client is used by the backend.  
The UI get’s an access\_token through the `grant_type=authorization_code` and then calls the backend with this access\_token. I then try to authorize the backend using this token in order to later get an RPT. But this fails with `{"error":"invalid_grant","error_description":"Invalid bearer token"}`.  
I looked throught the source code and it seems that the error is issued when the token issued by a public client and the session should be fetched : [github](https://github.com/keycloak/keycloak/blob/master/services/src/main/java/org/keycloak/protocol/oidc/endpoints/TokenEndpoint.java#L1083)  
This line fails : `authzClient.authorization(token)`  
Where token is the UI fetched token.

If I do an exercise and issue a token for the UI client through the grant\_type=password then the line above does not fail.

So - can somebody please explain what I’m doing wrong ?

---

<div class="post-metadata">

**Author:** ![arw357](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/arw357/32/9384_2.png) [@arw357](https://forum.keycloak.org/u/arw357)\
**Post date:** [November 14, 2019, 10:40am UTC](https://forum.keycloak.org/t/cant-use-access-token-issued-by-authorized-code-grant-for-another-client/402/2 "2019-11-14T10:40:36Z")

</div>

If everybody ever reads this - the problem was that the issuer was different in the UI than the `auth-server-url` provided for the backend .  
“iss”: “/y-keycloak/realms/my-realm”  
VS  
“iss”: “[http://keycloak:8090/y-keycloak/realms/my-realm](http://keycloak:8090/y-keycloak/realms/my-realm)”  
This is because docker network.  
https:// [issues.jboss.org/browse/KEYCLOAK-6073](http://issues.jboss.org/browse/KEYCLOAK-6073) is a solution
