PHP – Simple GitHub Login (OAuth)

If your codebase is in PHP and you would like user’s to be able to login to your site using GitHub (single sign-on) you can use the following as a good starting point:

Next you will need to setup an OAuth application within GitHub by doing the following:

  1. Login to GitHub.com.
  2. Go to your settings by clicking on your avatar image in the top-right corner of any GitHub page and then clicking on Settings in the drop-down menu.
  3. Scroll down to the Developer settings menu on the left and click OAuth Applications.
  4. Click the Register a new application button.
  5. Enter all of the necessary information to register your new OAuth application and then click Register application when you’re done.
  6. Take the Client ID and the Client Secret and place them in the constants defined in your PHP code from the beginning of this post.

That should be it. Now when you run this code you should be prompted to authorize your application to read your public information and private email addresses. You can remove the scope if you don’t need to be able to read any private information such as email addresses or you can change the scope after reviewing this page. If you want more information about OAuth apps for GitHub you can check out this page.

Happy coding! 😎

Install Watchtower Library On Mac (with Multiple Languages)

If you have a Mac and want to install the Watchtower Library on it chances are that you will be able to do it. Here is how:

  1. Download a “stable version” of WineBottler from the official site here.
  2. Open the WineBottler DMG file that you downloaded by double-clicking on it. Once open, drag-and-drop both Wine and WineBottler into the Applications directory.
  3. Open the Wine application from the Applications menu.
  4. In the menu bar at the top of the screen, select the Wine icon (Wine.app Icon) to pull down the menu and then select the File Manager.
  5. Your prefix will be setup:

  6. Once done, click OK to see the File Manager.
  7. In the Wine File Manager you will need to click on the / (Root Directory Button) button to open a panel for accessing your local file system.
  8. There are at least three different ways to install the Watchtower Library:

    1. From the Watchtower Library DVD:

      1. Insert the DVD.
      2. In the Wine File Manager you will need to click on the / (Root Directory Button) button to open a panel for accessing your local file system.
      3. Go into the Volumes directory and then into the directory with the name of your Watchtower Library DVD (eg. WTLIB16S).
        Wine File Manager
    2. From an archive file (eg. ZIP):

      1. Uncompress the archive file. If this is a ZIP file you can simply double-click on it and once done a folder containing the uncompressed files will be selected.
      2. Open the uncompressed folder, finding the Setup.exe (or WTLSetup.exe) file.
      3. In the Wine File Manager you will need to click on the / (Root Directory Button) button to open a panel for accessing your local file system.
      4. Navigate to the folder which contains the Setup.exe (or WTLSetup.exe). For example, if your folder containing the uncompressed files is in your Downloads folder you will want to navigate to Users » user-name (eg. cwest in my case) » Downloads » name of the uncompressed folder.
    3. From a folder:

      1. Navigate to the folder which contains the Setup.exe. For example, if your folder containing Setup.exe (or WTLSetup.exe) is in your Downloads folder you will want to navigate to Users » user-name (eg. cwest in my case) » Downloads » name of the folder.
  9. Double-click the Setup.exe (or WTLSetup.exe) file.
  10. Click through the steps to install the Watchtower Library in the default location (normally C:\Program Files\Watchtower).
    Installation
  11. Repeat the previous 2 steps for each additional language if you have other languages in which you would like to install the Watchtower Library and if you have the media (DVD, archive file, or setup folder) to do so.
  12. Download this file and double-click it in Finder to unzip it.
  13. Move the uncompressed Watchtower Library.app to the Applications folder.
  14. Click on the Watchtower Library from the Applications menu in the Dock.
  15. Select Add Library from the list and then click OK.
  16. Navigate to your home directory (the folder with your user name).
  17. Open up Wine Files » drive_c » Program Files » Watchtower » Watchtower Library.
  18. Open up the folder representing the language that you want to start off with. If there is only one folder just open up that folder.
  19. Select the file wtlibrary.exe (the casing of the file name doesn’t matter).
  20. Enter the name of the language of the library that you selected in the previous step.

Finally Done!

Now you should see the Watchtower Library open.

Whenever you click on the Watchtower Library app you will now see a menu similar to this one:

Installing Another Language

  1. Click on the Watchtower Library from the Applications menu in the Dock.
  2. Select Other Options from the list.
  3. Select Add Library.
  4. Navigate to and select a wtlibrary.exe that hasn’t yet been selected.
  5. Enter the name of the language of this version of the Watchtower Library.
  6. Now Watchtower Library is setup for multiple languages.
  7. Now when you click on the Watchtower Library app again you will see multiple language entries.

Conclusion

I know that I wrote another post in April 2016, but I hope that this post will be more helpful. There are a few other advanced options that you can explore, but I hope that this solution simply works. If you encounter a problem or have some feedback please let me know. Have fun! 😎