Skip to content

Commit

Permalink
Merge pull request playgameservices#1296 from paulsalameh/patch-1
Browse files Browse the repository at this point in the history
Add Oauth Scopes to PlayGamesClientConfiguration
  • Loading branch information
claywilkinson authored Aug 9, 2016
2 parents c1a41f6 + 3e951b2 commit 4b63c90
Showing 1 changed file with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="PlayGamesClientConfiguration.cs" company="Google Inc.">
// <copyright file="PlayGamesClientConfiguration.cs" company="Google Inc.">
// Copyright (C) 2014 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,6 +19,7 @@ namespace GooglePlayGames.BasicApi
{
using GooglePlayGames.BasicApi.Multiplayer;
using GooglePlayGames.OurUtils;
using System.Collections.Generic;

/// <summary>
/// Provides configuration for <see cref="PlayGamesPlatform"/>. If you wish to use either Saved
Expand All @@ -44,6 +45,11 @@ public struct PlayGamesClientConfiguration
/// Flag indicating to request use of a player's Google+ social graph.
/// </summary>
private readonly bool mRequireGooglePlus;

/// <summary>
/// Array of scopes to be requested from user. None is considered as 'games_lite'.
/// </summary>
private readonly string[] mScopes;

/// <summary>
/// The invitation delegate.
Expand Down Expand Up @@ -72,6 +78,7 @@ private PlayGamesClientConfiguration(Builder builder)
this.mMatchDelegate = builder.GetMatchDelegate();
this.mPermissionRationale = builder.GetPermissionRationale();
this.mRequireGooglePlus = builder.HasRequireGooglePlus();
this.mScopes = builder.getScopes();
}

/// <summary>
Expand Down Expand Up @@ -99,6 +106,18 @@ public bool RequireGooglePlus
return mRequireGooglePlus;
}
}

/// <summary>
/// Gets a array of scopes to be requested from the user.
/// </summary>
/// <value>String array of scopes.</value>
public string[] Scopes
{
get
{
return mScopes;
}
}

/// <summary>
/// Gets the invitation delegate.
Expand Down Expand Up @@ -150,6 +169,11 @@ public class Builder
/// The flag to request Google+. Default is false.
/// </summary>
private bool mRequireGooglePlus = false;

/// <summary>
/// The scopes to request from the user. Default is none.
/// </summary>
private List<string> mScopes = null;

/// <summary>
/// The invitation delegate. Default is a no-op;
Expand Down Expand Up @@ -196,6 +220,24 @@ public Builder RequireGooglePlus()
return this;
}

/// <summary>
/// Requests an Oauth scope from the user.
/// </summary>
/// <remarks>
/// Not setting one will default to 'games_lite' and will not show a consent
/// dialog to the user. Valid examples are 'profile' and 'email'.
/// Full list: https://developers.google.com/identity/protocols/googlescopes
/// To exchange the auth code with an id_token (or user id) on your server,
/// you must add at least one scope.
/// </remarks>
/// <returns>The builder.</returns>
public Builder AddOauthScope(string scope)
{
if (mScopes == null) mScopes = new List<string>();
mScopes.Add(scope);
return this;
}

/// <summary>
/// Adds the invitation delegate. This is called when an invitation
/// is received.
Expand Down Expand Up @@ -261,6 +303,14 @@ internal bool HasRequireGooglePlus()
return mRequireGooglePlus;
}

/// <summary>
/// Gets the Oauth scopes to be requested from the user.
/// </summary>
/// <returns>String array of scopes.</returns>
internal string[] getScopes() {
return mScopes == null? new string[0] : mScopes.ToArray();
}

/// <summary>
/// Gets the match delegate.
/// </summary>
Expand Down

0 comments on commit 4b63c90

Please sign in to comment.