Add support to request permission for adding moment types
This commit is contained in:
@@ -188,12 +188,14 @@ namespace Owin.Security.Providers.GooglePlus
|
||||
"&scope=" + Uri.EscapeDataString(scope) +
|
||||
"&state=" + Uri.EscapeDataString(state);
|
||||
|
||||
// Check if offline access was requested
|
||||
if (Options.RequestOfflineAccess)
|
||||
authorizationEndpoint += "&access_type=offline";
|
||||
//"&request_visible_actions=http://schemas.google.com/AddActivity" +
|
||||
//"&approval_prompt=force" +
|
||||
//"&include_granted_scopes=true"
|
||||
;
|
||||
|
||||
// Request the moment types
|
||||
if (Options.MomentTypes.Count > 0)
|
||||
authorizationEndpoint += String.Format("&request_visible_actions={0}",
|
||||
String.Join(" ", Options.MomentTypes));
|
||||
|
||||
Response.Redirect(authorizationEndpoint);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,12 @@ namespace Owin.Security.Providers.GooglePlus
|
||||
/// </summary>
|
||||
public string ClientSecret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of moment types which you application wants to write. During authentication this will be passed through via the request_visible_actions parameter.
|
||||
/// For more information of the moment types you may request, see https://developers.google.com/+/api/moment-types/
|
||||
/// </summary>
|
||||
public IList<string> MomentTypes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IGooglePlusAuthenticationProvider" /> used in the authentication events
|
||||
/// </summary>
|
||||
@@ -98,6 +104,7 @@ namespace Owin.Security.Providers.GooglePlus
|
||||
Caption = Constants.DefaultAuthenticationType;
|
||||
CallbackPath = new PathString("/signin-googleplus");
|
||||
AuthenticationMode = AuthenticationMode.Passive;
|
||||
MomentTypes = new List<string>();
|
||||
Scope = new List<string>
|
||||
{
|
||||
"https://www.googleapis.com/auth/plus.login",
|
||||
|
||||
@@ -50,17 +50,22 @@ namespace OwinOAuthProvidersDemo
|
||||
|
||||
//app.UseGitHubAuthentication("", "");
|
||||
|
||||
var options = new GooglePlusAuthenticationOptions
|
||||
{
|
||||
ClientId = "",
|
||||
ClientSecret = "",
|
||||
RequestOfflineAccess = true,
|
||||
Provider = new GooglePlusAuthenticationProvider
|
||||
{
|
||||
OnAuthenticated = async context => System.Diagnostics.Debug.WriteLine(String.Format("Refresh Token: {0}", context.RefreshToken))
|
||||
}
|
||||
};
|
||||
app.UseGooglePlusAuthentication(options);
|
||||
|
||||
//var options = new GooglePlusAuthenticationOptions
|
||||
//{
|
||||
// ClientId = "",
|
||||
// ClientSecret = "",
|
||||
// RequestOfflineAccess = true,
|
||||
// Provider = new GooglePlusAuthenticationProvider
|
||||
// {
|
||||
// OnAuthenticated = async context => System.Diagnostics.Debug.WriteLine(String.Format("Refresh Token: {0}", context.RefreshToken))
|
||||
// }
|
||||
//};
|
||||
//options.MomentTypes.Add("http://schemas.google.com/AddActivity");
|
||||
//options.MomentTypes.Add("http://schemas.google.com/CheckInActivity");
|
||||
//options.MomentTypes.Add("http://schemas.google.com/BuyActivity");
|
||||
//app.UseGooglePlusAuthentication(options);
|
||||
|
||||
|
||||
//app.UseOpenIDAuthentication("http://me.yahoo.com/", "Yahoo");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user