examples

command
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2018 License: MIT Imports: 8 Imported by: 0

README

OAuth1 Examples

Twitter

Authorization Flow (PIN-based)

An application can obtain a Twitter access Token for a user by requesting the user grant access via 3-legged or PIN-based OAuth 1. Here is a command line example showing PIN-based authorization.

export TWITTER_CONSUMER_KEY=xxx
export TWITTER_CONSUMER_SECRET=xxx
go run twitter-login.go

The OAuth 1 flow can be used to implement Login with Twitter. Upon receiving an access token in a callback handler on your server, issue a user some form of unforgeable session identifier (i.e. cookie, token). Note that web backends should use a real CallbackURL, "oob" is for PIN-based agents such as the command line.

Authorized Requests

Use the access Token to make requests on behalf of a Twitter user.

export TWITTER_CONSUMER_KEY=xxx
export TWITTER_CONSUMER_SECRET=xxx
export TWITTER_ACCESS_TOKEN=xxx
export TWITTER_ACCESS_SECRET=xxx
go run twitter-request.go

Tumblr

Authorization Flow

An application can obtain a Tumblr access Token to act on behalf of a user. Here is a command line example which requests permission.

export TUMBLR_CONSUMER_KEY=xxx
export TUMBLR_CONSUMER_SECRET=xxx
go run tumblr-login.go
Authorized Requests

Use the access Token to make requests on behalf of a Tumblr user.

export TUMBLR_CONSUMER_KEY=xxx
export TUMBLR_CONSUMER_SECRET=xxx
export TUMBLR_ACCESS_TOKEN=xxx
export TUMBLR_ACCESS_SECRET=xxx
go run tumblr-request.go

Note that only some Tumblr endpoints require OAuth1 signed requests, other endpoints require a special consumer key query parameter or no authorization.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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