package
1.0.17
Repository: https://github.com/parinyapt/golang_utils.git
Documentation: pkg.go.dev

# README

PTGU OAuth Facebook

Import

import (
	PTGUoauth "github.com/parinyapt/golang_utils/oauth/facebook/v1"
)

Example

Config OAuth

facebookOAuth := PTGUoauth.NewFacebookOAuth(&oauth2.Config{
  RedirectURL:  "URL_TO_REDIRECT_AFTER_LOGIN",
  ClientID:     "CLIENT_ID",
  ClientSecret: "CLIENT_SECRET",
  Scopes: []string{
    "email",
    "public_profile",
  },
  Endpoint: facebook.Endpoint,
})

Generate Login URL

loginURL := facebookOAuth.GenerateLoginURL("STATE")

Get User Access Token by Code

userAccessToken, err := facebookOAuth.GetUserAccessToken("CODE")
if err != nil {
  panic(err)
}
fmt.Println("User Access Token :", userAccessToken.AccessToken)
fmt.Println("User Access Token Expire in :", userAccessToken.ExpiresIn)

Get App Access Token

appAccessToken, err := favebookOAuth.GetAppAccessToken()
if err != nil {
  panic(err)
}
fmt.Println("App Access Token :", appAccessToken.AccessToken)

Get Token Info by Access Token

tokenInfo, err := favebookOAuth.GetTokenInfo(PTGUoauth.ParamFacebookGetTokenInfo{
  AppAccesstoken: "APP_ACCESS_TOKEN",
  UserAccessToken: "USER_ACCESS_TOKEN",
})
if err != nil {
  panic(err)
}
fmt.Println("User ID :", tokenInfo.Data.UserID)
fmt.Println("App ID :", tokenInfo.Data.AppID)

Get User Info by Access Token

userInfo, err := favebookOAuth.GetUserInfo("USER_ACCESS_TOKEN")
if err != nil {
  panic(err)
}
fmt.Println("User ID :", userInfo.ID)
fmt.Println("User Name :", *userInfo.Name)
fmt.Println("User Email :", *userInfo.Email)
fmt.Println("User Picture :", *userInfo.Picture.Data.URL)

# Functions

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author