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
public class MicrosoftGraphAuthProvider : OAuth2Provider, IAuthPlugin, IOAuthProvider, IAuthProvider
Properties
PhotoUrl
View Source
public static Func<string, string> PhotoUrl { get; set; }
SavePhoto
View Source
public bool SavePhoto { get; set; }
SavePhotoSize
View Source
public string SavePhotoSize { get; set; }
Tenant
View Source
public string Tenant { get; set; }
AppId
View Source
public string AppId { get; set; }
AppSecret
View Source
public string AppSecret { get; set; }
Inherited Properties
ResolveUnknownDisplayName
Custom DisplayName resolver function when not provided
View Source
public Func<IAuthSession, IAuthTokens, string> ResolveUnknownDisplayName { get; set; }
ResponseMode
View Source
public string ResponseMode { get; set; }
Scopes
View Source
public string[] Scopes { get; set; }
Fields
Name
View Source
public const string Name = "microsoftgraph"
Realm
View Source
public const string Realm = "https://graph.microsoft.com/v1.0/me"
DefaultUserProfileUrl
View Source
public const string DefaultUserProfileUrl = "https://graph.microsoft.com/v1.0/me"
DefaultPhotoUrl
View Source
public static Func<string, string> DefaultPhotoUrl
Methods
GetAccessTokenJsonAsync(String, AuthContext, CancellationToken)
View Source
protected override async Task<string> GetAccessTokenJsonAsync(string code, AuthContext ctx, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.String>
Parameters
Type | Name |
---|---|
System.String | code |
ServiceStack.Auth.AuthContext | ctx |
System.Threading.CancellationToken | token |
CreateAuthInfoAsync(String, CancellationToken)
View Source
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
Type | Name |
---|---|
System.String | accessToken |
System.Threading.CancellationToken | token |
OnAuthenticatedAsync(IServiceBase, IAuthSession, IAuthTokens, Dictionary<String, String>, CancellationToken)
View Source
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
Type | Name |
---|---|
ServiceStack.IServiceBase | authService |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthTokens | tokens |
System.Collections.Generic.Dictionary<System.String,System.String> | authInfo |
System.Threading.CancellationToken | token |
LoadUserOAuthProviderAsync(IAuthSession, IAuthTokens)
View Source
public override async Task LoadUserOAuthProviderAsync(IAuthSession authSession, IAuthTokens tokens)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.Auth.IAuthSession | authSession |
ServiceStack.Auth.IAuthTokens | tokens |
Inherited Methods
AssertAccessTokenUrl()
View Source
protected virtual void AssertAccessTokenUrl()
AssertAuthorizeUrl()
View Source
protected virtual void AssertAuthorizeUrl()
AssertValidState()
View Source
protected override void AssertValidState()
AuthenticateAsync(IServiceBase, IAuthSession, Authenticate, CancellationToken)
View Source
public override async Task<object> AuthenticateAsync(IServiceBase authService, IAuthSession session, Authenticate request, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Object>
Parameters
Type | Name |
---|---|
ServiceStack.IServiceBase | authService |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Authenticate | request |
System.Threading.CancellationToken | token |
AuthenticateWithAccessTokenAsync(IServiceBase, IAuthSession, IAuthTokens, String, Dictionary<String, String>, CancellationToken)
View Source
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
Type | Name |
---|---|
ServiceStack.IServiceBase | authService |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthTokens | tokens |
System.String | accessToken |
System.Collections.Generic.Dictionary<System.String,System.String> | authInfo |
System.Threading.CancellationToken | token |
CreateAuthInfoAsync(String, CancellationToken)
View Source
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
Type | Name |
---|---|
System.String | accessToken |
System.Threading.CancellationToken | token |
GetAccessTokenJsonAsync(String, AuthContext, CancellationToken)
View Source
protected virtual async Task<string> GetAccessTokenJsonAsync(string code, AuthContext ctx, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.String>
Parameters
Type | Name |
---|---|
System.String | code |
ServiceStack.Auth.AuthContext | ctx |
System.Threading.CancellationToken | token |
GetUserAuthName(IAuthTokens, Dictionary<String, String>)
Override to return User chosen username or Email for this AuthProvider
View Source
protected virtual string GetUserAuthName(IAuthTokens tokens, Dictionary<string, string> authInfo)
Returns
System.String
Parameters
Type | Name |
---|---|
ServiceStack.Auth.IAuthTokens | tokens |
System.Collections.Generic.Dictionary<System.String,System.String> | authInfo |
LoadUserAuthInfoAsync(AuthUserSession, IAuthTokens, Dictionary<String, String>, CancellationToken)
View Source
protected override Task LoadUserAuthInfoAsync(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.AuthUserSession | userSession |
ServiceStack.Auth.IAuthTokens | tokens |
System.Collections.Generic.Dictionary<System.String,System.String> | authInfo |
System.Threading.CancellationToken | token |
LoadUserOAuthProviderAsync(IAuthSession, IAuthTokens)
View Source
public override Task LoadUserOAuthProviderAsync(IAuthSession authSession, IAuthTokens tokens)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.Auth.IAuthSession | authSession |
ServiceStack.Auth.IAuthTokens | tokens |