gpsoauth

package module
v0.0.0-...-a90363e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 5 Imported by: 1

README

Ad hoc Go client package for Google Play Services OAuth

Inspired by the gpsoauth Python library.

Usage

For now, you can use this package to fetch an access token for authentication (that's my usecase) as follows:

package main

import (
	"fmt"
	"log"

	"github.com/kjedeligmann/gpsoauth"
)

func main() {
	var email, masterToken, gaid, scopes string // you should have credentials and API scopes

	resp, err := gpsoauth.PerformOAuthWithDefaults(
		email,
		masterToken,
		gaid, // Google Advertising ID, or Android ID
		scopes,
		"com.google.android.keep")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(resp["Auth"]) // access token
}

This is similar to this piece of code.

You can also fetch a master token for your account:

	resp, err := gpsoauth.ExchangeTokenWithDefaults(email, webToken, gaid)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resp["Token"]) // master token

You can learn more about obtaining webToken here. Overview of Google Play Services OAuth flow can be found here.

Documentation

Overview

Ad hoc Go client package for Google Play Services OAuth.

Index

Constants

View Source
const (
	DefaultClientSig = "38918a453d07199354f8b19af05ec6562ced5788"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthResponse

type AuthResponse map[string]string

func ExchangeToken

func ExchangeToken(
	email,
	webToken,
	gaid,
	service,
	clientSig,
	deviceCountry,
	operatorCountry,
	lang string,
	sdkVersion int) (AuthResponse, error)

func ExchangeTokenWithDefaults

func ExchangeTokenWithDefaults(email, webToken, gaid string) (AuthResponse, error)

func PerformOAuth

func PerformOAuth(
	email,
	masterToken,
	gaid,
	service,
	app,
	clientSig,
	deviceCountry,
	operatorCountry,
	lang string,
	sdkVersion int) (AuthResponse, error)

func PerformOAuthWithDefaults

func PerformOAuthWithDefaults(
	email,
	masterToken,
	gaid,
	service,
	app string) (AuthResponse, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL