Linkedin Authorization
1. Create Linkedin App
-
Enter your app page, then click
Create App
button.
Then switch to Auth Tab
get ClientId
and ClientSecret
.
- Add
Callback URL
warning
Important Note
Client secrets
can protect the security of your application, so please ensure that it is not leaked!
Also, do not share your client secrets
with anyone!!!
2. Integration GAuth
- Install GAuth
go get github.com/LeoInnovateLab/gauth
import register
import (
_ "github.com/LeoInnovateLab/gauth/register"
)
- Create AuthRequest
authRequest, err := gauth.New().
Source("linkedin").
ClientId("your_app_id").
ClientSecret("your_app_secret").
RedirectUrl("your_callback_url").
Build()
- Generate Authorize URL
authorizeUrl, err := authRequest.Authorize(utils.CreateState())
You can use this authorizeUrl
to redirect.
3. Authorization
Authorization result
"data": {
}
Demo
Recommend using GAuth Demo for testing.
-
Fill in the requested
App Id
andApp secrets
in.env.demo
-
Then, Start project, visit
http://localhost:8080/