Categorygithub.com/franciscoescher/golinkedin
modulepackage
1.5.0
Repository: https://github.com/franciscoescher/golinkedin.git
Documentation: pkg.go.dev

# README

Go LinkedIn

This is a Go client library for the LinkedIn API.

Installation

go get github.com/franciscoescher/golinkedin

Usage

Fiest, you need to create a client builder with your api key credentials using golinkedin.NewBuilder.

Then, you need to get the auth url to redirect the user to the linkedin login page using builder.GetAuthURL.

The user needs to access the url, login and accept the permissions. After that, linkedin will redirect to the redirect url with a code parameter.

Finally, You need to use this code to authenticate and get the client using builder.GetClient.

This client will be able to call the linkedin api.

package main

import (
	"context"
  "fmt"

  "github.com/franciscoescher/golinkedin"
)

func main() {
  // first, you need to create a builder with your api key credentials
  scopes := []string{"r_liteprofile", "r_emailaddress"}
  builder := golinkedin.NewBuilder("CLIENT_ID", "CLIENT_SECRET", scopes, "REDIRECT_URL")

  // then, you need to get the auth url to redirect the user to the linkedin login page
  url := builder.GetAuthURL("state")
  fmt.Println(url)

  // after user accepts, linkedin will redirect to REDIRECT_URL with a code parameter
  // you need to use this code to authenticate and get the client
  code := "CODE"
  client, err := builder.GetClient(context.Background(), code)
  if err != nil {
    log.Fatal(err)
  }

  // now you can use the client to make requests
  profile, err := client.GetProfile()
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(profile)
}

Please, check the example folder for a working example that implements a server that handles the linkedin callback.

Note

This library is not complete. It only implements the endpoints that I needed.

People endpoint is not tested.

Feel free to contribute.

# Packages

No description provided by the author

# Functions

Newbuilder returns a new linkedin client, not yet authenticated.
No description provided by the author

# Constants

EndpointEmailAddress is the endpoint for email address api.
EndpointPrimaryContact is the endpoint for primary contact api.
EndpointProfile is the endpoint for profile api.

# Variables

EndpointPeopleListParts are the parts to build the endpoint for people list api.
EndpointPeopleParts are the parts to build the endpoint for people api.

# Structs

EmailAddress is the response from email address api.
Common struct for error response in linkedin API.
No description provided by the author
PrimaryContact is the response from primary contact api.
Profile is the response from profile api.

# Interfaces

builderInterface is the interface that wraps the basic GetAuthURL and GetClient methods.
No description provided by the author