https://github.com/wuriyanto48/go-social
a Pluggable OAuth client library for social login (Google, Facebook, Github, Linkedin, Microsoft Identity Platform)
https://github.com/wuriyanto48/go-social
azure azure-active-directory facebook facebook-api facebook-login github github-login go golang golang-http golang-library golang-package google google-login microsoft-identity-platform oauth2
Last synced: 3 months ago
JSON representation
a Pluggable OAuth client library for social login (Google, Facebook, Github, Linkedin, Microsoft Identity Platform)
- Host: GitHub
- URL: https://github.com/wuriyanto48/go-social
- Owner: wuriyanto48
- Created: 2018-09-18T11:20:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-11T05:21:06.000Z (about 2 years ago)
- Last Synced: 2025-07-18T19:33:26.922Z (4 months ago)
- Topics: azure, azure-active-directory, facebook, facebook-api, facebook-login, github, github-login, go, golang, golang-http, golang-library, golang-package, google, google-login, microsoft-identity-platform, oauth2
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 14
- Watchers: 1
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Pluggable OAuth library for social login (Google, Facebook, Github, Linkedin)
[](https://godoc.org/github.com/wuriyanto48/go-social)
[](https://travis-ci.org/wuriyanto48/go-social)
[](https://circleci.com/gh/wuriyanto48/go-social)
[](https://forthebadge.com) [](https://forthebadge.com) [](https://forthebadge.com)
### Install
```shell
$ go get github.com/wuriyanto48/go-social
```
### Usage
OAuth2 using Facebook login
* Getting Authorization Code First
`https://www.facebook.com/dialog/oauth?client_id={your_client_id}&redirect_uri=http://localhost:8080/callback&response_type=code`
* Place the Authorization Code to the second parameter of `GetAccessToken(ctx, "authorization_code")` function
```go
package main
import (
"context"
"fmt"
"github.com/wuriyanto48/go-social"
"github.com/wuriyanto48/go-social/pkg/facebook"
)
func main() {
f, err := social.New(social.Facebook, "client_id", "client_secret", "", "http://localhost:8080/callback", "", 0)
if err != nil {
fmt.Println(err)
}
// using context for cancellation
ctx := context.Background()
err = f.GetAccessToken(ctx, "authorization_code")
if err != nil {
fmt.Println(err)
}
result, err := f.GetUser(ctx)
if err != nil {
fmt.Println(err)
}
user, _ := result.(*facebook.User)
fmt.Println(user.Picture)
}
```
### Todo
- Add Twitter implementation