Microsoft Graph SDK for Go

Overview

Microsoft Graph SDK for Go

PkgGoDev

Get started with the Microsoft Graph SDK for Go by integrating the Microsoft Graph API into your Go application!

Note: this SDK allows you to build applications using the v1.0 of Microsoft Graph. If you want to try the latest Microsoft Graph APIs under beta, use our beta SDK instead.

Note: the Microsoft Graph Go SDK is currently in Community Preview. During this period we're expecting breaking changes to happen to the SDK based on community's feedback. Checkout the known limitations.

1. Installation

go get -u github.com/microsoftgraph/msgraph-sdk-go
go get -u github.com/Azure/azure-sdk-for-go/sdk/azidentity

2. Getting started

2.1 Register your application

Register your application by following the steps at Register your app with the Microsoft Identity Platform.

2.2 Create an AuthenticationProvider object

An instance of the GraphRequestAdapter class handles building client. To create a new instance of this class, you need to provide an instance of AuthenticationProvider, which can authenticate requests to Microsoft Graph.

For an example of how to get an authentication provider, see choose a Microsoft Graph authentication provider.

Note: we are working to add the getting started information for Go to our public documentation, in the meantime the following sample should help you getting started.

import (
    azidentity "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
    a          "github.com/microsoft/kiota/authentication/go/azure"
    "context"
)

cred, err := azidentity.NewDeviceCodeCredential(&azidentity.DeviceCodeCredentialOptions{
    TenantID: "<the tenant id from your app registration>",
    ClientID: "<the client id from your app registration>",
    UserPrompt: func(ctx context.Context, message azidentity.DeviceCodeMessage) error {
        fmt.Println(message.Message)
        return nil
    },
})

if err != nil {
    fmt.Printf("Error creating credentials: %v\n", err)
}

auth, err := a.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{"Mail.Read", "Mail.Send"})
if err != nil {
    fmt.Printf("Error authentication provider: %v\n", err)
    return
}

2.3 Get a Graph Service Client Adapter object

You must get a GraphRequestAdapter object to make requests against the service.

import msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"

adapter, err := msgraphsdk.NewGraphRequestAdapter(auth)
if err != nil {
    fmt.Printf("Error creating adapter: %v\n", err)
    return
}
client := msgraphsdk.NewGraphServiceClient(adapter)

3. Make requests against the service

After you have a GraphServiceClient that is authenticated, you can begin making calls against the service. The requests against the service look like our REST API.

3.1 Get the user's drive

To retrieve the user's drive:

result, err := client
  .Me()
  .Drive()
  .Get(nil)
if err != nil {
    fmt.Printf("Error getting the drive: %v\n", err)
}
fmt.Printf("Found Drive : %v\n", result.GetId())

4. Documentation

For more detailed documentation, see:

5. Issues

For known issues, see issues.

6. Contributions

The Microsoft Graph SDK is open for contribution. To contribute to this project, see Contributing.

7. License

Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.

8. Third-party notices

Third-party notices

Issues
  • Query Parameters are not working due to missing $ prefix in logic

    Query Parameters are not working due to missing $ prefix in logic

    As mentioned in #114, AddQueryParameters which sets the $search, $expand, $top, $skip etc. in github.com/microsoft/[email protected]/request_information.go is using reflection to name the parameters which you are adding to your URLs in all API calls (e.g. (m *UsersRequestBuilder) CreateGetRequestInformation(options *UsersRequestBuilderGetOptions)).

    Unfortunately you need to inject some additional logic as the MS Graph query parameters require the $ ODATA prefix.

    This means no API calls work as soon as you supply query parameters (so no paging, no filtering, no field fetching) otherwise you get an error like:

    Request_BadRequest: Unrecognized query argument specified: 'top,skip'.: error status code received from the API

    I believe you should be able to fix this inside this library - the logic in microsoft/kiota-abstractions-go isn't wrong, you just can't use the final results in this library because of MS graph API / OData requirements for the $ prefix.

    bug question fixed service issue 
    opened by tommed 33
  • Trying to add member to group

    Trying to add member to group

    Hello,

    Using this example to attempt to add a member to an azure ad group.

    I have this bit of code

    graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
    
    requestBody := msgraphsdk.New()
    requestBody.SetAdditionalData(map[string]interface{}{
    	"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/<userid>",
    }
    groupId := "<objectid for group>"
    add, err := graphClient .GroupsById(&groupId).Members().Ref().Post(requestBody)
    

    I get below error

    Exception has occurred: panic
    "interface conversion: interface is nil, not ref.Refable"
    Stack:
    	3  0x0000000000c73d37 in github.com/microsoftgraph/msgraph-sdk-go/groups/item/members/ref.(*RefRequestBuilder).PostWithRequestConfigurationAndResponseHandler
    	    at /home/anthony/go/pkg/mod/github.com/microsoftgraph/[email protected]/groups/item/members/ref/ref_request_builder.go:142
    	4  0x0000000000c73977 in github.com/microsoftgraph/msgraph-sdk-go/groups/item/members/ref.(*RefRequestBuilder).Post
    	    at /home/anthony/go/pkg/mod/github.com/microsoftgraph/[email protected]/groups/item/members/ref/ref_request_builder.go:126
    

    It seems to be this line specifically that is panicking https://github.com/microsoftgraph/msgraph-sdk-go/blob/main/groups/item/members/ref/ref_request_builder.go#L144

    When debugging things I notice that the value for res Here is github.com/microsoft/kiota-abstractions-go/serialization.Parsable nil which I believe explains the error I'm getting

    Its possible I'm doing something horrible wrong, namely the add line add, err := graphClient .GroupsById(&groupId).Members().Ref().Post(requestBody) Am I using the .Ref() portion properly?

    Oddly enough the user is being added to the group successfully. So the add is working minus the fatal panic 😄

    question fixed service issue blocked 
    opened by amarbut24 23
  • There is no way to list items in the drive

    There is no way to list items in the drive

    It seems like there's currently no way of actually listing drive items. Requests like: GET /me/drive/root/children or GET /drives/{drive-id}/items/{item-id}/children are not possible using this sdk it seems.

    I would expect to be able to do something like client.Me().Drive().Root().Children().Get(nil)

    Am I missing something or is this just not possible? Also it seems that it's possible to construct invalid requests as in doing GET /drive/items and it just fails silently.

    bug fixed 
    opened by augbed 23
  • Regression in API behavior between v0.26.0 and the newly published v0.29.0

    Regression in API behavior between v0.26.0 and the newly published v0.29.0 "UpdateUser"

    First Issue:

    Previously using v0.26.0, the below snippet of code ran without any issue, however after upgrading to v0.29.0 I'm getting the following error "API call failed with the following error(s): \n > Message: Resource '' does not exist or one of its queried reference-property objects are not present.\n > Code: Request_ResourceNotFound\n"

    The reason for calling update immediately after creating the invite is because the Invitation api does not allow a user to set the firstName (givenname) and lastName (surname) fields, so those have to be done separately as another api call.

    func (gc *msgraphclient) CreateUser(u *User) (*User, error) {
    
    	if u == nil {
    		return nil, ErrUserNotSpecified
    	}
    
    	requestBody := models.NewInvitation()
    	requestBody.SetInvitedUserEmailAddress(&u.Username)
    	inviteRedirectUrl := fmt.Sprintf("https://portal.azure.com/%s", gc.config.TenantId)
    	requestBody.SetInviteRedirectUrl(&inviteRedirectUrl)
    	requestBody.SetInvitedUserDisplayName(&u.DisplayName)
    
    	resp, err := gc.appClient.Invitations().Post(requestBody)
    	if err != nil {
    		return nil, err
    	}
    
    	u.Id = *resp.GetInvitedUser().GetId()
    	_, err = gc.UpdateUser(u)
    	if err != nil {
    		log.Error("error updating user after creating invitation")
    		return nil, err
    	}
    	return u, nil
    }
    
    func (gc *msgraphclient) UpdateUser(u *User) (*User, error) {
    
    	if u == nil {
    		return nil, ErrUserNotSpecified
    	}
    
    	requestBody := models.NewUser()
    	requestBody.SetAccountEnabled(&u.AccountEnabled)
    	requestBody.SetDisplayName(&u.DisplayName)
    	requestBody.SetGivenName(&u.GivenName)
    	requestBody.SetSurname(&u.Surname)
    	requestBody.SetMail(&u.Email)
    
    	err := gc.appClient.UsersById(u.Id).Patch(requestBody)
    	if err != nil {
    		return nil, err
    	}
    
    	return u, nil
    }
    

    Second Issue:

    Even with the below code, which is able to successfully find the user by email, throws the same error as the first issue when trying to update existing users (both invitation & non-invitation) in the Microsoft Graph.

    func (gc *msgraphclient) UpdateUser(emailAddress, firstName, lastName string) error {
    
    	err := g.EnsureGraphForAppOnlyAuth()
    	if err != nil {
    		return err
    	}
    
    	targetUser, _ := gc.FindUserByEmail(emailAddress)
    	targetUser.SetGivenName(&firstName)
    	targetUser.SetSurname(&lastName)
    
    	err = g.appClient.UsersById(*targetUser.GetId()).Patch(targetUser)
    	if err != nil {
    		return err
    	}
    
    	return nil
    }
    
    func (gc *msgraphclient) FindUserByEmail(email string) (models.Userable, error) {
    
    	filter := fmt.Sprintf("mail eq '%s' and creationType eq 'Invitation'", email)
    	fields := []string{"id", "userPrincipalName", "displayName", "givenName", "surname", "mail", "accountEnabled"}
    	requestParameters := &users.UsersRequestBuilderGetQueryParameters{
    		Filter: &filter,
    		Select: fields,
    	}
    	options := &users.UsersRequestBuilderGetRequestConfiguration{
    		QueryParameters: requestParameters,
    	}
    
    	resp, err := gc.appClient.Users().GetWithRequestConfigurationAndResponseHandler(options, nil)
    	if err != nil {
    		return nil, err
    	}
    
    	users := resp.GetValue()
    	if len(users) <= 0 {
    		return nil, errors.New("user not found")
    	} else if len(users) > 1 {
    		return nil, errors.New("duplicate users found")
    	}
    	msUser := users[0]
    
    	return msUser, nil
    }
    

    Given the above, all signs point to there being a critical regression in the logic for the UpdateUser endpoint.

    Just for context, I've tried using both the object ID and userPrincipalName as "userId" values when calling the UpdateUser method, neither makes a difference and I still get an error.

    P.S - The same "UpdateUser" function above which previously executed without any issue sometimes throws the following error as well but I'm not able to consistently reproduce --> Specified HTTP method is not allowed for the request target.\n > Code: Request_BadRequest\n

    bug fixed 
    opened by abjoseph 19
  • New Users throwing inconsistent error

    New Users throwing inconsistent error

    Hello,

    I'm using this SDK to create new Azure AD users newUser, err := c.Users().Post(requestBody) is a snippet of the code I'm using

    While testing the code in my lab there are times when the Post will randomly fail I've extracted the error Code and Message when it fails

    Code=BadRequest
    message=Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.
    

    There aren't any failures logged in Azure (which makes sense based on the error)

    I'm wondering why (if anything) can be done to prevent this error As I said the error is very intermittent. If I run the code again right away it might succeed.

    For example, I added a test to range over 5 users and create them. If I run it 10-15 times I would say every time I run it I'll get at least 1-2 failures. There is no rhyme or reason which users will fail. I suppose I could write my own retry where if that error presents itself it just tries again, but figured I would reach out in case I'm missing something

    bug fixed 
    opened by amarbut24 17
  • Can't call Post() method to create/modify objects

    Can't call Post() method to create/modify objects

    Hi,

    I'd like to add a user to a group, according to the documentation and the code I should make this kind of call:

    graphClient.GroupsById(idGroup).MembersById(idUser).Post(directoryobject)
    

    However, the Post method doesn't exist, same thing happen if I want to add a user to a directoryRole.

    I might be missing something, but I can't figure it out.

    Thanks for your work :)

    fixed service issue 
    opened by hugo-syn 14
  • Query parameter does not work properly when retrieving users

    Query parameter does not work properly when retrieving users

    Hi

    I have created a sample program to retrieve a user, but the query parameter does not seem to be working correctly. When I debug it, it seems that the query parameter is not set correctly, is it still a limitation?

    The following sample query for the CreatedDateTime property to be included in the response, but returns NULL.

    func getUser(client *msgraphsdk.GraphServiceClient, id string) {
    
    	options := &usersitem.UserRequestBuilderGetOptions{
    		Q: &usersitem.UserRequestBuilderGetQueryParameters{
    			Select_escaped: []string{"createdDateTime"},
    		},
    	}
    	result, err := client.UsersById(id).Get(options)
    	if err != nil {
    		fmt.Printf("Error get user : %v\n", err)
    		return
    	}
    
    	fmt.Printf("result.GetDisplayName(): %v\n",result.GetDisplayName())
    	fmt.Printf("result.GetCreatedDateTime(): %v\n", result.GetCreatedDateTime())
    }
    

    Thanks.

    bug fixed 
    opened by m-moris 14
  • How do I get the delegated API permissions for an application from the graph API?

    How do I get the delegated API permissions for an application from the graph API?

    I'm not able to figure out how to use the API to retrieve the api permissions assigned to my application. This is the page of permissions I want to retrieve via the graph api. I'm using the API listed here: https://docs.microsoft.com/en-us/graph/api/serviceprincipal-list-delegatedpermissionclassifications?view=graph-rest-1.0&tabs=http. However, it doesn't seem to return any delegated permissions. The error is probably on my end, and I'm likely using the wrong API. Would someone be able to point me in the right direction for retrieving the "API Permissions" through the graph api? Thanks!

    // setup client *msgraphsdk.GraphServiceClient (clipped for brevity)
    permissions, er := client.ServicePrincipalsById(id).DelegatedPermissionClassifications().Get(nil)
    if er != nil {
    	fmt.Printf("error: %s %v\n", er, permissions)
    	return er
    }
    
    piterator, er := msgraphcore.NewPageIterator(permissions, adapter.GraphRequestAdapterBase, graph.CreateDelegatedPermissionClassificationCollectionResponseFromDiscriminatorValue)
    if er != nil {
    	fmt.Printf("error: %s %v\n", er, permissions)
    	return er
    }
    
    er = piterator.Iterate(func(pageItem interface{}) bool {
    	p := pageItem.(*graph.DelegatedPermissionClassification)
    	fmt.Printf("permission grant for id: %s -> %s %s\n", foundId, *p.GetId(), *p.GetPermissionName())
    	return true
    })
    
    permissions-2 question Needs Attention :wave: 
    opened by praetorian-thendrickson 12
  • Compiler error when using msgraphgocore.NewPageIterator

    Compiler error when using msgraphgocore.NewPageIterator

    The examples in the Readme and on the microsoft docs (https://docs.microsoft.com/en-us/graph/sdks/paging?tabs=Go) give examples like this for creating a page iterator

    pageIterator, err := msgraphcore.NewPageIterator(result, adapter.GraphRequestAdapterBase,
        func() serialization.Parsable {
            return messages.NewMessagesResponse()
        })
    

    However, this results in a compiler error:

    cannot use func literal (type func() serialization.Parsable) as type serialization.ParsableFactory in argument to msgraphgocore.NewPageIterator
    

    And the NewPageIterator function is defined like https://github.com/microsoftgraph/msgraph-sdk-go-core/blob/bc08a7c420acc78d4788f3adf0b9ef986f68fe77/page_iterator.go#L49, which takes a ParsableFactory and not a Parsable func. I think this was the commit that changed the interface (https://github.com/microsoftgraph/msgraph-sdk-go-core/commit/63efd75fcd80c130dd9d01055d97143c04f5cc06).

    func NewPageIterator(res interface{}, reqAdapter GraphRequestAdapterBase, constructorFunc serialization.ParsableFactory) (*PageIterator, error) {
    

    I'm very new to the library, but I can't figure out how to or find a working example of creating a pageIterator. How might I go about doing so? All the examples I've found in the docs generate that error. Here is the example code to reproduce the compiler error (mostly copied from the Readme example in this repository). Thanks for your help!

    package main
    
    import (
    	"context"
    	"fmt"
    
    	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
    	"github.com/microsoft/kiota/abstractions/go/serialization"
    	a "github.com/microsoft/kiota/authentication/go/azure"
    	msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
    	msgraphcore "github.com/microsoftgraph/msgraph-sdk-go-core"
    	"github.com/microsoftgraph/msgraph-sdk-go/models/microsoft/graph"
    	users "github.com/microsoftgraph/msgraph-sdk-go/users"
    )
    
    func main() {
    
    	cred, err := azidentity.NewDeviceCodeCredential(&azidentity.DeviceCodeCredentialOptions{
    		TenantID: "<the tenant id from your app registration>",
    		ClientID: "<the client id from your app registration>",
    		UserPrompt: func(ctx context.Context, message azidentity.DeviceCodeMessage) error {
    			fmt.Println(message.Message)
    			return nil
    		},
    	})
    
    	if err != nil {
    		fmt.Printf("Error creating credentials: %v\n", err)
    	}
    
    	auth, err := a.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{"Files.Read"})
    	if err != nil {
    		fmt.Printf("Error authentication provider: %v\n", err)
    		return
    	}
    
    	adapter, err := msgraphsdk.NewGraphRequestAdapter(auth)
    	if err != nil {
    		fmt.Printf("Error creating adapter: %v\n", err)
    		return
    	}
    	client := msgraphsdk.NewGraphServiceClient(adapter)
    	result, err := client.Users().Get(nil)
    
    	if err != nil {
    		fmt.Printf("Error getting users: %v\n", err)
    	}
    
    	pageIterator, err := msgraphcore.NewPageIterator(result, adapter.GraphRequestAdapterBase,
    		func() serialization.Parsable {
    			return users.NewUsersResponse()
    		})
    
    	err = pageIterator.Iterate(func(pageItem interface{}) bool {
    		user := pageItem.(graph.User)
    		fmt.Printf("%s\n", *user.GetDisplayName())
    		// Return true to continue the iteration
    		return true
    	})
    }
    

    My go.mod file is using the most recent versions of the libraries:

    module main.go
    
    go 1.17
    
    require (
    	github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.2
    	github.com/microsoft/kiota/abstractions/go v0.0.0-20220315140630-e2d45e682974
    	github.com/microsoft/kiota/authentication/go/azure v0.0.0-20220315140630-e2d45e682974
    	github.com/microsoftgraph/msgraph-sdk-go v0.14.0
    	github.com/microsoftgraph/msgraph-sdk-go-core v0.0.15
    )
    
    require (
    	github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 // indirect
    	github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 // indirect
    	github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect
    	github.com/cjlapao/common-go v0.0.18 // indirect
    	github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
    	github.com/google/uuid v1.3.0 // indirect
    	github.com/kylelemons/godebug v1.1.0 // indirect
    	github.com/microsoft/kiota/http/go/nethttp v0.0.0-20220315140630-e2d45e682974 // indirect
    	github.com/microsoft/kiota/serialization/go/json v0.0.0-20220315140630-e2d45e682974 // indirect
    	github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect
    	github.com/yosida95/uritemplate/v3 v3.0.1 // indirect
    	golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f // indirect
    	golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
    	golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
    	golang.org/x/text v0.3.7 // indirect
    )
    
    documentation question Needs Attention :wave: 
    opened by praetorian-thendrickson 12
  • Serialization Method requires clarification

    Serialization Method requires clarification

    How can SDK be used to write retrieved items?

    In the code example: https://docs.microsoft.com/en-gb/graph/sdks/paging?tabs=Go

    The snippet highlights how to receive each Message from the Mailbox. Messages are defined [here][]

    The SerializationWriter Interface is defined within Kiota abstractions, but it is unclear which how to save a particular message to an app. Code is adapted from provided code above:

    target := "My Message"
    // Iterate over all pages (e.g. Messages)
    iterateErr := pageIterator.Iterate(func(pageItem interface{}) bool {
        message := pageItem.(models.Messageable)
        fmt.Printf("%s\n", *message.GetSubject())
        if target == *message.GetSubject() {
            entries := message.GetFieldDeserializers(). // MAP Key: <string> Type: func(serialization.ParseNode) error
            for key, value := in range entries{
                // NEED CODE FOR HERE
                val() // NOT VALID     
        // Return true to continue the iteration
        return true
    })
    

    How do you get the value out of the value? Golang produces the following error:

    not enough arguments in call to val
            have ()
            want (serialization.ParseNode)
    

    This item can be considered closed when the following items have been completed:

    • [x] Instruction on serialization has been verified
    • [x] Instruction on importing objects has been verified Documentation will have to wait until the design team specifies where the code snippets should live.
    question Needs Attention :wave: 
    opened by dadams39 11
  • Convert DirectoryObjects to User objects?

    Convert DirectoryObjects to User objects?

    Hi, I am using the GO SDK to fetch users and group information from AD. Because I have a lot of users, I am fetching groups first and then foreach group I get it's members.

    func fetchGroupMembers(*groups graph.Group) {
    	var dirObjList []graph.DirectoryObject = make([]graph.DirectoryObject, 0)
    	
    	for _, group := range groups {
    		page1, err := client.GroupsById(*group.GetId()).Members().Get(nil)
    		if err != nil {
    			return err
    		}
    		dirObjList = append(dirObjList, page1.GetValue()...)
    
    		//Iterator to iterate over remaining pages and fetch users
    		iterator, err := msgcore.NewPageIterator(page1, *adapter, func() serialization.Parsable {
    			return directoryobjects.NewDirectoryObjectsResponse()
    		})
    		if err != nil {
    			return err
    		}
    		callback := func(item interface{}) bool {
    			dirObjList = append(dirObjList, item.(graph.DirectoryObject))
    			return true
    		}
    		iterator.Iterate(callback)
    		fmt.Println("#Users: ", len(dirObjList))
    
    		//Here, I am expecting users object but I get directory objects
    		for _, u := range dirObjList {
    
    			//I need to access user object attributes like displayName and so on ...
    		}
    
    		match = false
    	}
    }
    

    Is there a way to convert graph.DirectoryObjects to graph.User objects? Or how should I go about this? Thanks. PS: This code is representational only.

    duplicate enhancement 
    opened by hanix 11
  • Generated v1.0 models and request builders using Kiota

    Generated v1.0 models and request builders using Kiota

    This pull request was automatically created by the GitHub Action, create pull request.

    The commit hash is 19ceb2253a83289ce60516f1778c178625c7d998.

    Important Check for unexpected deletions or changes in this PR.

    generated 
    opened by baywet 0
  • cloud.Configuration support for endpoints (AzureChinaCloud, AzureGovernmentCloud, AzurePrivateCloud)

    cloud.Configuration support for endpoints (AzureChinaCloud, AzureGovernmentCloud, AzurePrivateCloud)

    instead of using adapter.SetBaseUrl("https://microsoftgraph.chinaclouapi.cn/v1.0") (related to #26) maybe adapt the way how the azure-sdk-for-go is using cloud.Configuration for configuring endpoints.

    json representation of cloud.Configuration content for AzurePublicCloud:

    {
        "activeDirectoryAuthorityHost": "https://login.microsoftonline.com/",
        "services": {
            "resourceManager": {
                "audience": "https://management.core.windows.net/",
                "endpoint": "https://management.azure.com"
            },
            // this could be the service configuration for msgraph-sdk-go
            "microsoftGraph": {
                "audience": "https://graph.microsoft.com",
                "endpoint": "https://graph.microsoft.com"
            }
        }
    }
    

    which is initialised here: https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/azcore/arm/arm.go

    Inside the client creation (eg armresoruces, armauthorization, ...) the azure-sdk-for-go is using the AzurePublic endpoints by default and overwrites the endpoint if a cloud configuration is passed in the client options:

    func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) {
    	if options == nil {
    		options = &arm.ClientOptions{}
    	}
    	ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint
    	if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok {
    		ep = c.Endpoint
    	}
    
    	// ....
    }
    

    see https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/resources/armresources/zz_generated_client.go#L38

    enhancement 
    opened by mblaschke 1
  • Missing `verifiedPublisher` in `ServicePrincipal` response

    Missing `verifiedPublisher` in `ServicePrincipal` response

    Hi, I'm trying to list all service principals. But in the response, I didn't see any method defined to get the value for verifiedPublisher. https://github.com/microsoftgraph/msgraph-sdk-go/blob/2d3e4f1d94cf75bb5a722f555993907ced137aab/models/service_principalable.go#L8 image

    https://docs.microsoft.com/en-us/graph/api/resources/serviceprincipal?view=graph-rest-1.0

    bug service issue blocked 
    opened by Subhajit97 4
  • Missing `resourceBehaviorOptions` and `resourceProvisioningOptions` in `Group` response

    Missing `resourceBehaviorOptions` and `resourceProvisioningOptions` in `Group` response

    Hi, I'm trying to list all groups in my organization. But in the response, I didn't see any method defined to get the value for resourceBehaviorOptions and resourceProvisioningOptions. https://github.com/microsoftgraph/msgraph-sdk-go/blob/2d3e4f1d94cf75bb5a722f555993907ced137aab/models/groupable.go#L9 image image

    bug service issue blocked 
    opened by Subhajit97 1
  • 📢 Inaccurate Odata type information causing POST/PATCH/PUT to fail

    📢 Inaccurate Odata type information causing POST/PATCH/PUT to fail

    Starting at version 0.27.0 to 0.30.0 the Odata type property on models might be inaccurate (e.g. User has an OData type of #microsoft.graph.directoryObject instead of #microsoft.graph.user) which causes some write operations to fail.

    The error message might or might not reflect that aspect, it depends on the target API.

    We're working to fix the issue in the conversion library where it comes from so the information is accurate in this SDK.

    In the meantime you can either:

    • stick to version 0.26.0 with the drawback that some API paths/models will be missing and some other bugs that are now fixed are going to be present
    • add a model.SetType(nil) line before the failing POST/PATCH/PUT operations (GET/DELETE not impacted)

    We'll close this issue when the situation is resolved. Thanks to @abjoseph for reporting this on #212

    bug 
    opened by baywet 1
  • Allow passing context in requests

    Allow passing context in requests

    Currently the msgraph-sdk-go doesn't allow passing the context when making requests which removes the ability to cancel API requests when the context is canceled.

    Example usage could look like:

    user, err := client.Me().GetWithContext(ctx)
    
    user, err := client.Me().GetWithRequestConfigurationAndResponseHandlerWithContext(ctx, options, nil)
    
    enhancement 
    opened by jackhopner 10
Releases(v0.32.0)
Owner
Microsoft Graph
Unified endpoint for accessing data, relationships and insights coming from the Microsoft cloud
Microsoft Graph
Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs

PnPjs is a fluent JavaScript API for consuming SharePoint and Microsoft Graph REST APIs in a type-safe way. You can use it with SharePoint Framework,

Microsoft 365 Community 604 Aug 4, 2022
Microsoft Azure SDK for Go

Azure SDK for Go This repository is for active development of the Azure SDK for Go. For consumers of the SDK you can follow the links below to visit t

Microsoft Azure 1.1k Aug 6, 2022
A Facebook Graph API SDK For Go.

A Facebook Graph API SDK In Golang This is a Go package that fully supports the Facebook Graph API with file upload, batch request and marketing API.

Huan Du 1.1k Aug 8, 2022
A go sdk for baidu netdisk open platform 百度网盘开放平台 Go SDK

Pan Go Sdk 该代码库为百度网盘开放平台Go语言的SDK

Jsyz Chen 74 Aug 3, 2022
Nextengine-sdk-go: the NextEngine SDK for the Go programming language

NextEngine SDK for Go nextengine-sdk-go is the NextEngine SDK for the Go programming language. Getting Started Install go get github.com/takaaki-s/nex

null 0 Dec 7, 2021
Commercetools-go-sdk is fork of original commercetools-go-sdk

commercetools-go-sdk The Commercetools Go SDK is automatically generated based on the official API specifications of Commercetools. It should therefor

Flink 0 Dec 13, 2021
Sdk-go - Go version of the Synapse SDK

synapsesdk-go Synapse Protocol's Go SDK. Currently in super duper alpha, do not

null 0 Jan 7, 2022
Redash-go-sdk - An SDK for the programmatic management of Redash, in Go

Redash Go SDK An SDK for the programmatic management of Redash. The main compone

RecoLabs 25 Jul 28, 2022
null 92 Aug 8, 2022
Graph Role-Based Access Control by Animeshon

gRBAC - Graph Role-Based Access Control A cloud-native graph implementation of the Role-Based Access Control (RBAC) authorization architecture powered

gRBAC 18 Jul 28, 2022
AWS SDK for the Go programming language.

AWS SDK for Go aws-sdk-go is the official AWS SDK for the Go programming language. Checkout our release notes for information about the latest bug fix

Amazon Web Services 7.8k Aug 3, 2022
A Golang SDK for Medium's OAuth2 API

Medium SDK for Go This repository contains the open source SDK for integrating Medium's OAuth2 API into your Go app. Install go get github.com/Medium/

Medium 131 May 18, 2022
MinIO Client SDK for Go

MinIO Go Client SDK for Amazon S3 Compatible Cloud Storage The MinIO Go Client SDK provides simple APIs to access any Amazon S3 compatible object stor

High Performance, Kubernetes Native Object Storage 1.7k Jul 31, 2022
Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK)

simples3 : Simple no frills AWS S3 Library using REST with V4 Signing Overview SimpleS3 is a golang library for uploading and deleting objects on S3 b

Rohan Verma 89 Jul 31, 2022
Twilight is an unofficial Golang SDK for Twilio APIs

Twilight is an unofficial Golang SDK for Twilio APIs. Twilight was born as a result of my inability to spell Twilio correctly. I searched for a Twillio Golang client library and couldn’t find any, I decided to build one. Halfway through building this, I realized I had spelled Twilio as Twillio when searching for a client library on Github.

Ghvst Code 18 Jul 2, 2021
Wechat Pay SDK(V3) Write by Go.

WechatPay GO(v3) Introduction Wechat Pay SDK(V3) Write by Go. API V3 of Office document is here. Features Signature/Verify messages Encrypt/Decrypt ce

luoji 23 May 23, 2022
Go Wechaty is a Conversational SDK for Chatbot Makers Written in Go

go-wechaty Connecting Chatbots Wechaty is a RPA SDK for Wechat Individual Account that can help you create a chatbot in 6 lines of Go. Voice of the De

Wechaty 249 Aug 3, 2022
An easy-to-use unofficial SDK for Feishu and Lark Open Platform

go-lark go-lark is an easy-to-use unofficial SDK for Feishu and Lark Open Platform. go-lark implements messaging APIs, with full-fledged supports on b

go-lark-sdk 106 Aug 6, 2022
A go SDK for the data available via data.gov.gr

go-data-gov-gr-sdk A Go based SDK to access the public data provided by the Greek Government and are available at https://www.data.gov.gr/ Quick Start

Papapetrou Patroklos 23 Jan 24, 2022