TokenClient.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // <copyright file="TokenClient.cs" company="Google Inc.">
  2. // Copyright (C) 2015 Google Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. // </copyright>
  16. #if (UNITY_ANDROID || (UNITY_IPHONE && !NO_GPGS))
  17. namespace GooglePlayGames
  18. {
  19. using System;
  20. internal interface TokenClient
  21. {
  22. /// <summary>
  23. /// Gets the user's email.
  24. /// </summary>
  25. /// <remarks>The email address returned is selected by the user from the accounts present
  26. /// on the device. There is no guarantee this uniquely identifies the player.
  27. /// For unique identification use the id property of the local player.
  28. /// The user can also choose to not select any email address, meaning it is not
  29. /// available.</remarks>
  30. /// <returns>The user email or null if not authenticated or the permission is
  31. /// not available.</returns>
  32. string GetEmail();
  33. string GetAuthCode();
  34. string GetIdToken();
  35. /// <summary>
  36. /// Gets another server auth code.
  37. /// </summary>
  38. /// <remarks>This method should be called after authenticating, and exchanging
  39. /// the initial server auth code for a token. This is implemented by signing in
  40. /// silently, which if successful returns almost immediately and with a new
  41. /// server auth code.
  42. /// </remarks>
  43. /// <param name="reAuthenticateIfNeeded">Calls Authenticate if needed when
  44. /// retrieving another auth code. </param>
  45. /// <param name="callback">Callback.</param>
  46. void GetAnotherServerAuthCode(bool reAuthenticateIfNeeded,
  47. Action<string> callback);
  48. void Signout();
  49. void SetRequestAuthCode(bool flag, bool forceRefresh);
  50. void SetRequestEmail(bool flag);
  51. void SetRequestIdToken(bool flag);
  52. void SetWebClientId(string webClientId);
  53. void SetAccountName(string accountName);
  54. void AddOauthScopes(string[] scopes);
  55. void SetHidePopups(bool flag);
  56. bool NeedsToRun();
  57. void FetchTokens(Action<int> callback);
  58. }
  59. }
  60. #endif