Skip to content

Commit

Permalink
Merge pull request revel#9 from theothertomelliott/master
Browse files Browse the repository at this point in the history
Update Facebook example to use golang.org/x/oauth2
  • Loading branch information
pedromorgan committed Jan 26, 2016
2 parents 1782126 + f5d177c commit 803c389
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions facebook-oauth2/app/controllers/app.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package controllers

import (
"code.google.com/p/goauth2/oauth"
"encoding/json"
"fmt"
"github.com/revel/revel"
"github.com/revel/samples/facebook-oauth2/app/models"
"net/http"
"net/url"
"strconv"

"github.com/revel/revel"
"github.com/revel/samples/facebook-oauth2/app/models"
"golang.org/x/oauth2"
"golang.org/x/oauth2/facebook"
)

type Application struct {
Expand All @@ -20,11 +22,11 @@ type Application struct {
// You need to bind loisant.org to your machine with /etc/hosts to
// test the application locally.

var FACEBOOK = &oauth.Config{
ClientId: "95341411595",
ClientSecret: "8eff1b488da7fe3426f9ecaf8de1ba54",
AuthURL: "https://graph.facebook.com/oauth/authorize",
TokenURL: "https://graph.facebook.com/oauth/access_token",
var FACEBOOK = &oauth2.Config{
ClientID: "943076975742162",
ClientSecret: "d3229ebe3501771344bb0f2db2324014",
Scopes: []string{},
Endpoint: facebook.Endpoint,
RedirectURL: "http://loisant.org:9000/Application/Auth",
}

Expand All @@ -41,13 +43,13 @@ func (c Application) Index() revel.Result {
revel.INFO.Println(me)
}

authUrl := FACEBOOK.AuthCodeURL("foo")
authUrl := FACEBOOK.AuthCodeURL("state", oauth2.AccessTypeOffline)
return c.Render(me, authUrl)
}

func (c Application) Auth(code string) revel.Result {
t := &oauth.Transport{Config: FACEBOOK}
tok, err := t.Exchange(code)

tok, err := FACEBOOK.Exchange(oauth2.NoContext, code)
if err != nil {
revel.ERROR.Println(err)
return c.Redirect(Application.Index)
Expand Down

0 comments on commit 803c389

Please sign in to comment.