Skip to content

Commit

Permalink
Rewrite auth to use new client interface. Add new auth client for loc…
Browse files Browse the repository at this point in the history
…al web authentication.
  • Loading branch information
mhoc committed Apr 29, 2018
1 parent 7c4f9d9 commit 71c4f2b
Show file tree
Hide file tree
Showing 11 changed files with 363 additions and 120 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
# "ClientSecret": "as09djfa9sjdf",
# "TenantID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
# }
test.json
test.json

main.go
msgoraph
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
build:
go build github.com/mhoc/msgoraph
go build github.com/mhoc/msgoraph/auth
go build github.com/mhoc/msgoraph/common
go build github.com/mhoc/msgoraph/internal
go build github.com/mhoc/msgoraph/users
vgo build github.com/mhoc/msgoraph
vgo build github.com/mhoc/msgoraph/client
vgo build github.com/mhoc/msgoraph/common
vgo build github.com/mhoc/msgoraph/internal
vgo build github.com/mhoc/msgoraph/scopes
vgo build github.com/mhoc/msgoraph/users

docs:
@echo "http://localhost:6060/pkg/github.com/mhoc/msgoraph/"
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

A zero dependency Go Client for [Microsoft's Graph API](https://developer.microsoft.com/en-us/graph/docs/concepts/overview). This is built and distributed under all of the philosophies of [vgo](https://research.swtch.com/vgo) for future compatibility, but should work with a simple `go get`, `dep`, or your package management tool of choice until `vgo` is stable.

## Stability Warning
## Disclaimers

This library is pre-release, under active development, and has no tests. We will do our best to ensure that tagged releases are stable enough to use the functionality they export, but bugs could happen. Becuase this is pre-release, the Go Import Compatibility Rule does not apply and backward-incompatible changes should be expected between minor pre-release versions. Make sure to pin your version.
This library is completely unaffiliated with Microsoft.

This library is pre-release, under active development, and has no tests. We will do our best to ensure that tagged releases are stable enough to use the functionality they export, but bugs could happen.

This library is in pre-release, and as such the Go Import Compatibility Rule does not apply. Backward-incompatible changes should be expected between all tagged versions and commits.

## Supported Operations

Expand Down
90 changes: 0 additions & 90 deletions auth/credentials.go

This file was deleted.

3 changes: 0 additions & 3 deletions auth/doc.go

This file was deleted.

30 changes: 30 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package client

import (
"sync"
"time"
)

// Client is an interface which all client types abide by. It guarantees operations around
// credentials; primarily getting, initializing, and refreshing.
type Client interface {
Credentials() *RequestCredentials

// InitializeCredentials should make the initial requests necessary to establish the first set of
// authentication credentials within the Client.
InitializeCredentials() error

// RefreshCredentials should initiate an internal refresh of the request credentials inside this
// client. This refresh should, whenever possible, check the
// RequestCredentials.AccessTokenExpiresAt field to determine whether it should actually refresh
// the credentials or if the credentials are still valid.
RefreshCredentials() error
}

// RequestCredentials stores all the information necessary to authenticate a request with the
// Microsoft GraphAPI
type RequestCredentials struct {
AccessToken string
AccessTokenExpiresAt time.Time
AccessTokenUpdating sync.Mutex
}
3 changes: 3 additions & 0 deletions client/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package client implements client state, authentication, pagination, type helpers, and method
// helpers concerning accessing resources in the Microsoft Graph API.
package client
Loading

0 comments on commit 71c4f2b

Please sign in to comment.