Skip to main content

MicrosoftGraphAuthProvider

Create an Microsoft Graph App at: https://apps.dev.microsoft.com The Apps Callback URL should match the CallbackUrl here.

Microsoft Graph Info: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-overview Microsoft Graph Scopes: https://developer.microsoft.com/en-us/graph/docs/concepts/permissions_reference

Assembly: ServiceStack.dll
View Source
Declaration
public class MicrosoftGraphAuthProvider : OAuth2Provider, IAuthPlugin, IOAuthProvider, IAuthProvider

Properties

PhotoUrl

View Source
Declaration
public static Func<string, string> PhotoUrl { get; set; }

SavePhoto

View Source
Declaration
public bool SavePhoto { get; set; }

SavePhotoSize

View Source
Declaration
public string SavePhotoSize { get; set; }

Tenant

View Source
Declaration
public string Tenant { get; set; }

AppId

View Source
Declaration
public string AppId { get; set; }

AppSecret

View Source
Declaration
public string AppSecret { get; set; }

Inherited Properties

ResolveUnknownDisplayName

Custom DisplayName resolver function when not provided

View Source
Declaration
public Func<IAuthSession, IAuthTokens, string> ResolveUnknownDisplayName { get; set; }

ResponseMode

View Source
Declaration
public string ResponseMode { get; set; }

Scopes

View Source
Declaration
public string[] Scopes { get; set; }

Fields

Name

View Source
Declaration
public const string Name = "microsoftgraph"

Realm

View Source
Declaration
public const string Realm = "https://graph.microsoft.com/v1.0/me"

DefaultUserProfileUrl

View Source
Declaration
public const string DefaultUserProfileUrl = "https://graph.microsoft.com/v1.0/me"

DefaultPhotoUrl

View Source
Declaration
public static Func<string, string> DefaultPhotoUrl

Methods

GetAccessTokenJsonAsync(String, AuthContext, CancellationToken)

View Source
Declaration
protected override async Task<string> GetAccessTokenJsonAsync(string code, AuthContext ctx, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<System.String>

Parameters
TypeName
System.Stringcode
ServiceStack.Auth.AuthContextctx
System.Threading.CancellationTokentoken

CreateAuthInfoAsync(String, CancellationToken)

View Source
Declaration
protected override async Task<Dictionary<string, string>> CreateAuthInfoAsync(string accessToken, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<System.String,System.String>>

Parameters
TypeName
System.StringaccessToken
System.Threading.CancellationTokentoken

OnAuthenticatedAsync(IServiceBase, IAuthSession, IAuthTokens, Dictionary<String, String>, CancellationToken)

View Source
Declaration
public override async Task<IHttpResult> OnAuthenticatedAsync(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary<string, string> authInfo, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<ServiceStack.Web.IHttpResult>

Parameters
TypeName
ServiceStack.IServiceBaseauthService
ServiceStack.Auth.IAuthSessionsession
ServiceStack.Auth.IAuthTokenstokens
System.Collections.Generic.Dictionary<System.String,System.String>authInfo
System.Threading.CancellationTokentoken

LoadUserOAuthProviderAsync(IAuthSession, IAuthTokens)

View Source
Declaration
public override async Task LoadUserOAuthProviderAsync(IAuthSession authSession, IAuthTokens tokens)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Auth.IAuthSessionauthSession
ServiceStack.Auth.IAuthTokenstokens

Inherited Methods

AssertAccessTokenUrl()

View Source
Declaration
protected virtual void AssertAccessTokenUrl()

AssertAuthorizeUrl()

View Source
Declaration
protected virtual void AssertAuthorizeUrl()

AssertValidState()

View Source
Declaration
protected override void AssertValidState()

AuthenticateAsync(IServiceBase, IAuthSession, Authenticate, CancellationToken)

View Source
Declaration
public override async Task<object> AuthenticateAsync(IServiceBase authService, IAuthSession session, Authenticate request, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<System.Object>

Parameters
TypeName
ServiceStack.IServiceBaseauthService
ServiceStack.Auth.IAuthSessionsession
ServiceStack.Authenticaterequest
System.Threading.CancellationTokentoken

AuthenticateWithAccessTokenAsync(IServiceBase, IAuthSession, IAuthTokens, String, Dictionary<String, String>, CancellationToken)

View Source
Declaration
protected virtual async Task<object> AuthenticateWithAccessTokenAsync(IServiceBase authService, IAuthSession session, IAuthTokens tokens, string accessToken, Dictionary<string, string> authInfo = null, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<System.Object>

Parameters
TypeName
ServiceStack.IServiceBaseauthService
ServiceStack.Auth.IAuthSessionsession
ServiceStack.Auth.IAuthTokenstokens
System.StringaccessToken
System.Collections.Generic.Dictionary<System.String,System.String>authInfo
System.Threading.CancellationTokentoken

CreateAuthInfoAsync(String, CancellationToken)

View Source
Declaration
protected abstract Task<Dictionary<string, string>> CreateAuthInfoAsync(string accessToken, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<System.String,System.String>>

Parameters
TypeName
System.StringaccessToken
System.Threading.CancellationTokentoken

GetAccessTokenJsonAsync(String, AuthContext, CancellationToken)

View Source
Declaration
protected virtual async Task<string> GetAccessTokenJsonAsync(string code, AuthContext ctx, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<System.String>

Parameters
TypeName
System.Stringcode
ServiceStack.Auth.AuthContextctx
System.Threading.CancellationTokentoken

GetUserAuthName(IAuthTokens, Dictionary<String, String>)

Override to return User chosen username or Email for this AuthProvider

View Source
Declaration
protected virtual string GetUserAuthName(IAuthTokens tokens, Dictionary<string, string> authInfo)
Returns

System.String

Parameters
TypeName
ServiceStack.Auth.IAuthTokenstokens
System.Collections.Generic.Dictionary<System.String,System.String>authInfo

LoadUserAuthInfoAsync(AuthUserSession, IAuthTokens, Dictionary<String, String>, CancellationToken)

View Source
Declaration
protected override Task LoadUserAuthInfoAsync(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.AuthUserSessionuserSession
ServiceStack.Auth.IAuthTokenstokens
System.Collections.Generic.Dictionary<System.String,System.String>authInfo
System.Threading.CancellationTokentoken

LoadUserOAuthProviderAsync(IAuthSession, IAuthTokens)

View Source
Declaration
public override Task LoadUserOAuthProviderAsync(IAuthSession authSession, IAuthTokens tokens)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Auth.IAuthSessionauthSession
ServiceStack.Auth.IAuthTokenstokens

Implements