A Go library for doing header-based OAuth over HTTP or HTTPS.

Installation

goinstall github.com/alloy-d/goauth

Usage

import (
    "github.com/alloy-d/goauth"
    "os"
)

func someFuncThatDoesStuffWithOAuth() (err os.Error) {
    o := new (oauth.OAuth)
    o.ConsumerKey = "key"
    o.ConsumerSecret = "secret"
    o.Callback = "callback"

    o.RequestTokenURL = "https://api.twitter.com/oauth/request_token"
    o.OwnerAuthURL = "https://api.twitter.com/oauth/authorize"
    o.AccessTokenURL = "https://api.twitter.com/oauth/access_token"

    err = o.GetRequestToken()
    if err != nil { return }

    url, err := o.AuthorizationURL()
    if err != nil { return }

    // somehow send user to url...

    var verifier string
    // somehow get verifier (or "PIN")...

    err = o.GetAccessToken(verifier)
    if err != nil { return }

    err = o.Save(os.Getenv("HOME") + "/.simple_example.oauth")

    response, err := o.Post(
        "https://api.twitter.com/1/statuses/update.json",
        map[string]string{"status": "Just did a little OAuth dance!"})
    if err != nil { return }

    // do stuff with response...

    return nil
}

Status

This is still a bit of a work in progress. The interface is subject to change (and become prettier), but I think it's mostly done.

It is probably obvious that it's rough around the edges in spots. Please let me know if anything's broken.

Similar Resources

Server bridging Google's OAuth and service using Radius for authentication

Fringe Fringe is an easy workaround for Google Workplace users who need a Radius server to perform authentication on behalf of other services (e.g. 80

Mar 7, 2022

Demonstration of sharing secret data between an OAuth/OIDC client and an Identity Providers web client.

OAuth / OIDC Cubbyhole Share secret data between client applications. This is mostly a demonstration of some of the work I've been evaluating at Storj

Mar 21, 2022

Example of a simple application which is powered by a third-party oAuth 2.0 server for it's authentication / authorization. Written in Golang.

go mod init github.com/bartmika/osin-thirdparty-example go get github.com/spf13/cobra go get github.com/openshift/osin go get github.com/openshift/osi

Jan 4, 2022

OauthMicroservice-cassandraCluster - Implement microservice of oauth using golang and cassandra to store user tokens

implement microservice of oauth using golang and cassandra to store user tokens

Jan 24, 2022

Goauth: Pre-made OAuth/OpenIDConnect and general authorization hooks for webapp login

goauth Pre-made OAuth/OpenIDConnect and general authorization hooks for webapp login. Currently supports Google, Facebook and Microsoft "out of the bo

Jan 28, 2022

Go based HTTP server with 2FA based on OTP (One-Time Password) manager like Google Authenticator

Go based HTTP server with 2FA based on OTP (One-Time Password) manager like Goog

Aug 21, 2022

Time-Based One-Time Password (TOTP) and HMAC-Based One-Time Password (HOTP) library for Go.

otpgo HMAC-Based and Time-Based One-Time Password (HOTP and TOTP) library for Go. Implements RFC 4226 and RFC 6238. Contents Supported Operations Read

Dec 19, 2022

Identity-service - An OAuth2 identity provider that operates over gRPC

Identity-service - An OAuth2 identity provider that operates over gRPC

May 2, 2022

Identity - An OAuth2 identity provider that operates over gRPC

Otter Social Identity Provider An OAuth2 identity provider that operates over

May 2, 2022
Comments
  • Auth without files

    Auth without files

    I started building an NNTP interface to yammer and am using the oauth credentials for NNTP authentication. I needed a way to pass them in as a username/password pair without going through the filesystem. Since you can already use the filesystem to get to this data, it can't really be considered secret, so I figured I'd expose it so I can directly authenticate.

  • compile error during install

    compile error during install

    $ goinstall github.com/alloy-d/goauth goinstall: === cd /home/donp/src/go/repo/src/pkg/github.com/alloy-d/goauth; gomake -f- install 8g -o go.8 error.go helpers.go persist.go url.go oauth.go http.go http.go:60: not enough arguments in call to tls.Dial http.go:92: cannot use map literal (type map[string] string) as type http.Header in assignment http.go:100: invalid operation: req.Header["Authorization"] += ",\n " (mismatched types []string and string) http.go:102: invalid operation: req.Header["Authorization"] += (node ADDSTR) (mismatched types []string and string) http.go:121: cannot use map literal (type map[string] string) as type http.Header in assignment http.go:129: invalid operation: req.Header["Authorization"] += ",\n " (mismatched types []string and string) http.go:131: invalid operation: req.Header["Authorization"] += (node ADDSTR) (mismatched types []string and string) make: *** [go.8] Error 1 --- exit status 2 goinstall: installing github.com/alloy-d/goauth: running gomake: exit status 2

  • Updates for go weekly.2011-12-22 11100

    Updates for go weekly.2011-12-22 11100

    Hey, after trying several oauth clients, I finally found one that is well written and actually works. :)

    I'm using this in yammer.go and it's working pretty well.

Casdoor is a UI-first centralized authentication / Single-Sign-On (SSO) platform based on OAuth 2.0 / OIDC.

A UI-first centralized authentication / Single-Sign-On (SSO) platform based on OAuth 2.0 / OIDC

Dec 29, 2022
Authentication Plugin for implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0, SAML Authentication
Authentication Plugin for implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0, SAML Authentication

Authentication Plugin for implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0, SAML Authentication

Jan 8, 2023
A library for performing OAuth Device flow and Web application flow in Go client apps.
A library for performing OAuth Device flow and Web application flow in Go client apps.

oauth A library for Go client applications that need to perform OAuth authorization against a server, typically GitHub.com. Traditionally,

Dec 30, 2022
A library for Go client applications that need to perform OAuth authorization against a server
A library for Go client applications that need to perform OAuth authorization against a server

oauth-0.8.0.zip oauth A library for Go client applications that need to perform OAuth authorization against a server, typically GitHub.com. Traditiona

Oct 13, 2021
GOAuth An Oauth consumer Written in Go V 0.0.5

GOAuth ====== This is the source code repository for the GOAuth an OAuth consumer written on the Go programming language. Copyright 2010 The GOAuth

Feb 11, 2021
[NO LONGER MAINTAINED} oauth 2 server implementation in Go

hero hero is a feature rich oauth 2 server implementation in Go. Features User account management Client management oauth 2 rfc 6749 compliant Configu

Nov 18, 2022
OAuth 1.0a implementation in Go

Package oauth1a Summary An implementation of OAuth 1.0a in Go1. API reference Installing Run: go get github.com/kurrik/oauth1a Include in your source

Aug 23, 2022
OAuth 1.0 implementation in go (golang).

OAuth 1.0 Library for Go (If you need an OAuth 2.0 library, check out: https://godoc.org/golang.org/x/oauth2) Developing your own apps, with this libr

Nov 22, 2022
an SSO and OAuth / OIDC login solution for Nginx using the auth_request module
an SSO and OAuth / OIDC login solution for Nginx using the auth_request module

Vouch Proxy An SSO solution for Nginx using the auth_request module. Vouch Proxy can protect all of your websites at once. Vouch Proxy supports many O

Jan 4, 2023
OAuth 2.0 middleware service for chi (ported from gin by community member)

oauth middleware OAuth 2.0 Authorization Server & Authorization Middleware for go-chi This library was ported to go-chi from https://github.com/maxzer

Dec 8, 2022