Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grokify/beegoutil
OAuth 2.0 demo app for Beego using Google, Facebook, RingCentral and Aha!
https://github.com/grokify/beegoutil
beego beego-application golang golang-examples oauth2
Last synced: 25 days ago
JSON representation
OAuth 2.0 demo app for Beego using Google, Facebook, RingCentral and Aha!
- Host: GitHub
- URL: https://github.com/grokify/beegoutil
- Owner: grokify
- License: mit
- Created: 2017-06-17T15:28:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-07T10:45:18.000Z (30 days ago)
- Last Synced: 2024-10-11T00:33:27.778Z (26 days ago)
- Topics: beego, beego-application, golang, golang-examples, oauth2
- Language: Smarty
- Homepage:
- Size: 5.08 MB
- Stars: 10
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Beego OAuth 2.0 Demo
[![Build Status][build-status-svg]][build-status-url]
[![Go Report Card][goreport-svg]][goreport-url]
[![Docs][docs-godoc-svg]][docs-godoc-url]
[![License][license-svg]][license-url]A [Beego](https://beego.me/) example app to demo OAuth 2.0 using Google and Facebook.
![](docs/beego-oauth2-demo_login-page.png)
![](docs/beego-oauth2-demo_logged-in-page.png)
The following are used in this example app:
* OAuth 2.0
* [`oauth2`](https://github.com/golang/oauth2)
* [`goauth`](https://github.com/grokify/goauth)
* Rendering
* [Bootstrap](http://getbootstrap.com/)
* [Font Awesome](http://fontawesome.io/)
* [Social Buttons](https://lipis.github.io/bootstrap-social/)
* [Quicktemplate](https://github.com/valyala/quicktemplate)## Usage
### App Hostname / OAuth 2.0 Redirect URI
Decide on the hostname for your app which will be used in the OAuth 2.0 URI.
The redirect URI is `oauth2callback`. For example, if your app URL is `https://example.com`, your redirect URI will be `https://example.com/oauth2callback`.
If you do not have an Internet accessible hostname, you can use [ngrok](https://ngrok.com/) for testing.
### Configure Google and Facebook
Login to the Google and Facebbook developer consoles to configure your apps with your OAuth 2.0 rediect URIs. During this process, you will get your OAuth 2.0 client ID and client secrets for Google and Facebook.
### Install & Configure App
1. Clone the repo
2. Install the dependencies
3. Set up your `app.conf` file.
4. Run the appYou can do the above with the following steps. See the next section for more detailed information on the configuration file.
```bash
$ git clone https://github.com/grokify/beego-oauth2-demo
$ go get ./...
$ cd beego-oauth2-demo/conf
$ cp app.conf.sample app.conf
$ vim app.conf
$ bee run
```#### Configuration File
This is a basic Beego config file with additional properties. Specifically, it has the following 3 properties:
| Property | Description |
|----------|-------------|
| `oauth2redirecturi` | This app's OAuth2 redirect URI which has the path `/oauth2callback`, e.g. `https://example.com/oauth2callback` |
| `oauth2configgoogle` | The [Google Developers Console](https://console.developers.google.com/) `client_credentials.json` file information. Nagivate to "API Manager" > "Credentials" > "OAuth 2.0 client IDs" > > "Download JSON". This is read directly by OAuth2's `google.ConfigFromJSON()` function. |
| `oauth2configfacebook` | This uses the format used by `oauth2.Config` |## References
### Google Auth Credentials
App credentials are created an managed using the [Google Developers Console](https://console.developers.google.com/). To create an app, do the following:
1. Navigate to [Google Developers Console](https://console.developers.google.com/)
1. Click "API Manager"
1. Create / Select a Project
1. Click "Credentials"
1. Create / Select OAuth 2.0 client IDs for "Web application"
1. Click "Download JSON"[build-status-svg]: https://github.com/grokify/beegoutil/workflows/test/badge.svg
[build-status-url]: https://github.com/grokify/beegoutil/actions
[goreport-svg]: https://goreportcard.com/badge/github.com/grokify/beegoutil
[goreport-url]: https://goreportcard.com/report/github.com/grokify/beegoutil
[docs-godoc-svg]: https://pkg.go.dev/badge/github.com/grokify/beegoutil
[docs-godoc-url]: https://pkg.go.dev/github.com/grokify/beegoutil
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
[license-url]: https://github.com/grokify/beegoutil/blob/master/LICENSE