-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move oauth implementation into internal package, add documentation
- Loading branch information
1 parent
0e7cca8
commit 01a2f92
Showing
27 changed files
with
239 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,57 @@ | ||
# Hamilton is a Go SDK for Microsoft Graph | ||
|
||
This is an active work in progress and highly subject to change. | ||
This is a working Go client for the [Microsoft Graph API][ms-graph-docs]. It is actively maintained and has growing support for services and objects in Azure Active Directory. | ||
|
||
Do not use. | ||
## Example Usage | ||
|
||
```go | ||
package example | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/manicminer/hamilton/auth" | ||
"github.com/manicminer/hamilton/clients" | ||
) | ||
|
||
const ( | ||
tenantId = "00000000-0000-0000-0000-000000000000" | ||
clientId = "11111111-1111-1111-1111-111111111111" | ||
clientSecret = "My$3cR3t" | ||
) | ||
|
||
func main() { | ||
ctx := context.Background() | ||
|
||
authConfig := &auth.Config{ | ||
TenantID: tenantId, | ||
ClientID: clientId, | ||
ClientSecret: clientSecret, | ||
EnableClientSecretAuth: true, | ||
} | ||
|
||
authorizer, err := authConfig.NewAuthorizer(ctx) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
client := clients.NewUsersClient(tenantId) | ||
client.BaseClient.Authorizer = authorizer | ||
|
||
users, _, err := client.List(ctx, "") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
if users == nil { | ||
log.Fatalln("bad API response, nil result received") | ||
} | ||
|
||
for _, user := range *users { | ||
fmt.Printf("%s: %s <%s>\n", *user.ID, *user.DisplayName, *user.Mail) | ||
} | ||
} | ||
``` | ||
|
||
[ms-graph-docs]: https://docs.microsoft.com/en-us/graph/overview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.