ada-u / chatwork-oauth2-client-example

An example of ChatWork OAuth2 client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting started

1. OAuth2 client registration

client registration- ChatWork

$ cp .env.example .env

Edit OAUTH2_CLIENT_ID, OAUTH2_CLIENT_SECRET, OAUTH2_REDIRECT_URI.

$ vi .env

2. Enable SSL & generate a self-signed cert

$ cd laradoc
$ vi caddy/Caddyfile
diff --git a/caddy/Caddyfile b/caddy/Caddyfile
--- a/caddy/Caddyfile
+++ b/caddy/Caddyfile
@@ -1,5 +1,5 @@
 # Docs: https://caddyserver.com/docs/caddyfile
-0.0.0.0:80 {
+https://oauth2-chatwork.local {
     root /var/www/public
     fastcgi / php-fpm:9000 php {
         index index.php
@@ -17,7 +17,7 @@
     errors /var/log/caddy/error.log
     # Uncomment to enable TLS (HTTPS)
     # Change the first list to listen on port 443 when enabling TLS
-    #tls self_signed
+    tls self_signed

     # To use Lets encrpt tls with a DNS provider uncomment these
     # lines and change the provider as required
$ cd laradoc
$ docker-compose up caddy
(press CTRL+C after generating a self-signed cert)

3. Start servers

$ docker run --rm --interactive --tty --volume $PWD:/app composer install
$ cd laradoc 
$ docker-compose up -d mysql caddy

4. Access client

$ echo '127.0.0.1       oauth2-chatwork.local' >> /etc/hosts

Access https://oauth2-chatwork.local via browser

Sample code

Generate a consent page link

https://github.com/ada-u/chatwork-oauth2-client-example/blob/master/app/Http/Controllers/WelcomeController.php

Obtain an access token and refresh a token

https://github.com/ada-u/chatwork-oauth2-client-example/blob/master/app/Http/Controllers/CallbackController.php

License

MIT license.

About

An example of ChatWork OAuth2 client


Languages

Language:PHP 93.1%Language:HTML 6.2%Language:Vue 0.7%