msgraphsdkgo

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 110 Imported by: 110

README ¶

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

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

This section is empty.

Types ¶

type GraphRequestAdapter ¶

type GraphRequestAdapter struct {
	core.GraphRequestAdapterBase
}

GraphRequestAdapter is the core service used by GraphServiceClient to make requests to Microsoft Graph.

func NewGraphRequestAdapter ¶

func NewGraphRequestAdapter(authenticationProvider absauth.AuthenticationProvider) (*GraphRequestAdapter, error)

NewGraphRequestAdapter creates a new GraphRequestAdapter with the given parameters Parameters: authenticationProvider: the provider used to authenticate requests Returns: a new GraphRequestAdapter

func NewGraphRequestAdapterWithParseNodeFactory ¶

func NewGraphRequestAdapterWithParseNodeFactory(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory) (*GraphRequestAdapter, error)

NewGraphRequestAdapterWithParseNodeFactory creates a new GraphRequestAdapter with the given parameters Parameters: authenticationProvider: the provider used to authenticate requests parseNodeFactory: the factory used to create parse nodes Returns: a new GraphRequestAdapter

func NewGraphRequestAdapterWithParseNodeFactoryAndSerializationWriterFactory ¶

func NewGraphRequestAdapterWithParseNodeFactoryAndSerializationWriterFactory(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory, serializationWriterFactory absser.SerializationWriterFactory) (*GraphRequestAdapter, error)

NewGraphRequestAdapterWithParseNodeFactoryAndSerializationWriterFactory creates a new GraphRequestAdapter with the given parameters Parameters: authenticationProvider: the provider used to authenticate requests parseNodeFactory: the factory used to create parse nodes serializationWriterFactory: the factory used to create serialization writers Returns: a new GraphRequestAdapter

func NewGraphRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient ¶

func NewGraphRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory, serializationWriterFactory absser.SerializationWriterFactory, httpClient *nethttp.Client) (*GraphRequestAdapter, error)

NewGraphRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient creates a new GraphRequestAdapter with the given parameters Parameters: authenticationProvider: the provider used to authenticate requests parseNodeFactory: the factory used to create parse nodes serializationWriterFactory: the factory used to create serialization writers httpClient: the client used to send requests Returns: a new GraphRequestAdapter

type GraphServiceClient ¶

type GraphServiceClient struct {
	// contains filtered or unexported fields
}

The main entry point of the SDK, exposes the configuration and the fluent API.

func NewGraphServiceClient ¶

Instantiates a new GraphServiceClient and sets the default values. Parameters:

  • requestAdapter : The request adapter to use to execute the requests.

func (*GraphServiceClient) AgreementAcceptancesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.agreementAcceptances.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) AgreementsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.agreements.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) ApplicationTemplatesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.applicationTemplates.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) ApplicationsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.applications.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) AuthenticationMethodConfigurationsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.authenticationMethodConfigurations.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) CertificateBasedAuthConfigurationById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.certificateBasedAuthConfiguration.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) ChatsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.chats.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) ConnectionsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.connections.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) ContactsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.contacts.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) ContractsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.contracts.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) DataPolicyOperationsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.dataPolicyOperations.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) DevicesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.devices.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) DirectoryObjectsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.directoryObjects.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) DirectoryRoleTemplatesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.directoryRoleTemplates.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) DirectoryRolesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.directoryRoles.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) DomainDnsRecordsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.domainDnsRecords.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) DomainsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.domains.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) DrivesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.drives.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) Get ¶

func (*GraphServiceClient) GroupLifecyclePoliciesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.groupLifecyclePolicies.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) GroupSettingTemplatesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.groupSettingTemplates.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) GroupSettingsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.groupSettings.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) GroupsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.groups.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) IdentityProvidersById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.identityProviders.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) InvitationsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.invitations.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) LocalizationsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.localizations.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) Oauth2PermissionGrantsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.oauth2PermissionGrants.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) OrganizationById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.organization.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) PermissionGrantsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.permissionGrants.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) PlacesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.places.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) SchemaExtensionsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.schemaExtensions.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) ScopedRoleMembershipsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.scopedRoleMemberships.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) ServicePrincipalsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.servicePrincipals.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) SharesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.shares.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) SitesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.sites.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) SubscribedSkusById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.subscribedSkus.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) SubscriptionsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.subscriptions.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) TeamsById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.teams.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) TeamsTemplatesById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.teamsTemplates.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) UsersById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.users.item collection Parameters:

  • id : Unique identifier of the item

func (*GraphServiceClient) WorkbooksById ¶

Gets an item from the github.com/microsoftgraph/msgraph-sdk-go/.workbooks.item collection Parameters:

  • id : Unique identifier of the item

type GraphServiceClientGetOptions ¶

type GraphServiceClientGetOptions struct {
	// Request headers
	H map[string]string
	// Request options
	O []ida96af0f171bb75f894a4013a6b3146a4397c58f11adb81a2b7cbea9314783a9.RequestOption
	// Response handler to use in place of the default response handling provided by the core service
	ResponseHandler ida96af0f171bb75f894a4013a6b3146a4397c58f11adb81a2b7cbea9314783a9.ResponseHandler
}

Options for Get

Directories ¶

Path Synopsis
me
me
models
add

Jump to

Keyboard shortcuts

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