# Making Oauth2 work with slim

**URL:** <https://discourse.slimframework.com/t/making-oauth2-work-with-slim/1895>\
**Category:** Questions\
**Created:** [October 16, 2017, 9:51pm UTC](https://discourse.slimframework.com/t/making-oauth2-work-with-slim/1895 "2017-10-16T21:51:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pato.llaguno](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@pato.llaguno](https://discourse.slimframework.com/u/pato.llaguno)\
**Post date:** [October 16, 2017, 9:51pm UTC](https://discourse.slimframework.com/t/making-oauth2-work-with-slim/1895/1 "2017-10-16T21:51:09Z")

</div>

Hi, i am a bit new to slim, i am trying to implement a slim api project with Oauth capabilities, i have been using this skeleton [https://github.com/pabloroca/slim3-simple-rest-skeleton](https://github.com/pabloroca/slim3-simple-rest-skeleton) which uses [https://github.com/bshaffer/oauth2-server-php](https://github.com/bshaffer/oauth2-server-php) framework for it, for some reason i am not being able to make it work properly, and i am unsure if im just implementing something wrong. I added a user to users table and a client to the oauth\_clients table, what i am no t sure is what do i have to put on the coulmn scope, or is this irrelevant? since i am able to get my access token but when using the token to get info out of the books table i get a 401 error.

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [October 16, 2017, 10:51pm UTC](https://discourse.slimframework.com/t/making-oauth2-work-with-slim/1895/2 "2017-10-16T22:51:52Z")

</div>

I don’t know if this will help as I’m not familiar with those packages, but here is an example API app with OAuth 2 you may wish to look at.

[A simple Slim Framework API with OAuth 2 authentication.](https://github.com/akrabat/slim-bookshelf-api)

---

<div class="post-metadata">

**Author:** ![pato.llaguno](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@pato.llaguno](https://discourse.slimframework.com/u/pato.llaguno)\
**Post date:** [October 17, 2017, 4:10pm UTC](https://discourse.slimframework.com/t/making-oauth2-work-with-slim/1895/3 "2017-10-17T16:10:19Z")

</div>

Thx, that seems to be a good help and actually very lightweight way to implement, at least as i can see, the only thing is that i need it to work with MySQL and it is done for sqlite3 do you happen to know how to run that migrations package to a mysql database, i am looking and it seems it can be done but am having no luck.

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [October 18, 2017, 12:26am UTC](https://discourse.slimframework.com/t/making-oauth2-work-with-slim/1895/4 "2017-10-18T00:26:24Z")

</div>

I’ve never used [doctrine/migrations](http://docs.doctrine-project.org/projects/doctrine-migrations/en/latest/) so I’m not really sure, but it looks like the database type is defined [here](https://github.com/akrabat/slim-bookshelf-api/blob/master/api/src/settings.php#L13).

---

<div class="post-metadata">

**Author:** ![pato.llaguno](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@pato.llaguno](https://discourse.slimframework.com/u/pato.llaguno)\
**Post date:** [October 18, 2017, 1:17am UTC](https://discourse.slimframework.com/t/making-oauth2-work-with-slim/1895/5 "2017-10-18T01:17:46Z")

</div>

would it be much to ask to see if you get the same result as i do? when using this [https://github.com/pabloroca/slim3-simple-rest-skeleton](https://github.com/pabloroca/slim3-simple-rest-skeleton) code, i get the token correctly, but for some reason the token won’t let me get authorization, it returns 401 error

---

<div class="post-metadata">

**Author:** ![jucafloga](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@jucafloga](https://discourse.slimframework.com/u/jucafloga)\
**Post date:** [June 11, 2022, 9:15am UTC](https://discourse.slimframework.com/t/making-oauth2-work-with-slim/1895/6 "2022-06-11T09:15:03Z")

</div>

If you use apache try adding this line in your .htaccess file

CGIPassAuth On  
or  
RewriteRule .\* - [E=HTTP\_AUTHORIZATION:%{HTTP:Authorization}]
