Skip to content

Commit

Permalink
UPM package
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaina committed Oct 10, 2023
1 parent f453f6c commit 08010fc
Show file tree
Hide file tree
Showing 76 changed files with 138 additions and 226 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTING.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions GoogleSignIn.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "GoogleSignin"
}
7 changes: 7 additions & 0 deletions GoogleSignIn.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ internal Future(FutureAPIImpl<T> impl) {
/// <param name="tcs">Tcs.</param>
internal IEnumerator WaitForResult(TaskCompletionSource<T> tcs) {
yield return new WaitUntil(() => !Pending);
if (Status == GoogleSignInStatusCode.Canceled) {
if (Status == GoogleSignInStatusCode.CANCELED) {
tcs.SetCanceled();
} else if (Status == GoogleSignInStatusCode.Success ||
Status == GoogleSignInStatusCode.SuccessCached) {
} else if (Status == GoogleSignInStatusCode.SUCCESS ||
Status == GoogleSignInStatusCode.SUCCESS_CACHE) {
tcs.SetResult(Result);
} else {
tcs.SetException(new GoogleSignIn.SignInException(Status));
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static GoogleSignInConfiguration Configuration {
if (theInstance == null || theConfiguration == value || theConfiguration == null) {
theConfiguration = value;
} else {
throw new SignInException(GoogleSignInStatusCode.DeveloperError,
throw new SignInException(GoogleSignInStatusCode.DEVELOPER_ERROR,
"DefaultInstance already created. " +
" Cannot change configuration after creation.");
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class GoogleSignInConfiguration {
/// <summary>Request id token, requires consent.</summary>
public bool RequestIdToken = false;
/// <summary>Request profile information, requires consent.</summary>
public bool RequestProfile = false;
public bool RequestProfile = true;
/// <summary>Hides popup UIs from games services.</summary>
/// <remarks>Used with games signin to show or hide the connecting popup UI
/// and to associate an invisible view for other popups. This is
Expand Down
53 changes: 53 additions & 0 deletions GoogleSignIn/GoogleSignInStatusCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// <copyright file="GoogleSignInStatusCode.cs" company="Google Inc.">
// Copyright (C) 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

namespace Google {

/// <summary>
/// Status code for the SignIn operations.
/// </summary>
/// <remarks>All successful status codes are less than or equal to 0.
/// </remarks>
public enum GoogleSignInStatusCode {
SUCCESS_CACHE = -1,
SUCCESS = 0,
[System.Obsolete]
SERVICE_MISSING = 1,
[System.Obsolete]
SERVICE_VERSION_UPDATE_REQUIRED = 2,
[System.Obsolete]
SERVICE_DISABLED = 3,
SIGN_IN_REQUIRED = 4,
INVALID_ACCOUNT = 5,
RESOLUTION_REQUIRED = 6,
NETWORK_ERROR = 7,
INTERNAL_ERROR = 8,
SERVICE_INVALID = 9,
DEVELOPER_ERROR = 10,
LICENSE_CHECK_FAILED = 11,
ERROR = 13,
INTERRUPTED = 14,
TIMEOUT = 15,
CANCELED = 16,
API_NOT_CONNECTED = 17,
DEAD_CLIENT = 18,
REMOTE_EXCEPTION = 19,
CONNECTION_SUSPENDED_DURING_CALL = 20,
RECONNECTION_TIMED_OUT_DURING_UPDATE = 21,
RECONNECTION_TIMED_OUT = 22
}
} // namespace GoogleSignIn

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public SignInListener() : base("com.google.googlesignin.IListener")

public void OnResult(int result, AndroidJavaObject acct)
{

Debug.Log("googlesignin.IListener : " + acct.Call<string>("toString"));
Debug.Log("ID : " + acct.Call<string>("getId"));
}
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,11 @@ static HttpListener BindLocalHostFirstAvailablePort()
void SigningIn()
{
Debug.Log("SigningIn");
Pending = true;
var httpListener = BindLocalHostFirstAvailablePort();
try
{
var openURL = "https://accounts.google.com/o/oauth2/v2/auth?scope=openid email profile&response_type=code&redirect_uri=" + httpListener.Prefixes.FirstOrDefault() + "&client_id=" + configuration.WebClientId;
Debug.Log(openURL);
var openURL = "https://accounts.google.com/o/oauth2/v2/auth?" + Uri.EscapeUriString("scope=openid email profile&response_type=code&redirect_uri=" + httpListener.Prefixes.FirstOrDefault() + "&client_id=" + configuration.WebClientId);
Application.OpenURL(openURL);
}
catch(Exception e)
Expand All @@ -103,12 +101,10 @@ void SigningIn()
{
var context = task.Result;
var queryString = context.Request.Url.Query;
Debug.Log(queryString);
var queryDictionary = System.Web.HttpUtility.ParseQueryString(queryString);
if(queryDictionary == null || queryDictionary.Get("code") is not string code || string.IsNullOrEmpty(code))
{
Status = GoogleSignInStatusCode.InvalidAccount;
Debug.Log("no code? : " + context.Request.Url);
Status = GoogleSignInStatusCode.INVALID_ACCOUNT;
context.Response.StatusCode = 404;
context.Response.OutputStream.Write(Encoding.UTF8.GetBytes("Cannot get code"));
Expand All @@ -122,7 +118,6 @@ void SigningIn()
var result = await HttpWebRequest.CreateHttp("https://www.googleapis.com/oauth2/v4/token").Post("application/x-www-form-urlencoded","code=" + code + "&client_id=" + configuration.WebClientId + "&client_secret=" + configuration.ClientSecret + "&redirect_uri=" + httpListener.Prefixes.FirstOrDefault() + "&grant_type=authorization_code").ContinueWith((task) => task.Result,taskScheduler);
var jobj = JObject.Parse(result);
Debug.Log(jobj);
var accessToken = (string)jobj.GetValue("access_token");
var expiresIn = (int)jobj.GetValue("expires_in");
Expand Down Expand Up @@ -152,11 +147,11 @@ void SigningIn()
Result = user;
Status = GoogleSignInStatusCode.Success;
Status = GoogleSignInStatusCode.SUCCESS;
}
catch(Exception e)
{
Status = GoogleSignInStatusCode.Error;
Status = GoogleSignInStatusCode.ERROR;
Debug.LogException(e);
throw;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ public GoogleSignInUser Result {
var user = new GoogleSignInUser();
var userPtr = new HandleRef(user, ptr);

user.DisplayName = GoogleSignInImpl.GoogleSignIn_GetDisplayName(userPtr);
user.UserId = GoogleSignInImpl.GoogleSignIn_GetUserId(userPtr);

user.Email = GoogleSignInImpl.GoogleSignIn_GetEmail(userPtr);

user.DisplayName = GoogleSignInImpl.GoogleSignIn_GetDisplayName(userPtr);

user.FamilyName = GoogleSignInImpl.GoogleSignIn_GetFamilyName(userPtr);

user.GivenName = GoogleSignInImpl.GoogleSignIn_GetGivenName(userPtr);
Expand All @@ -65,7 +67,9 @@ public GoogleSignInUser Result {
user.ImageUrl = new System.Uri(url);
}

user.UserId = GoogleSignInImpl.GoogleSignIn_GetUserId(userPtr);
/** Require for no reason (tree shaking ?) */
var obj = (user.UserId,user.Email,user.DisplayName,user.FamilyName,user.GivenName,user.IdToken,user.AuthCode,user.ImageUrl);

return user;
}
}
Expand Down
File renamed without changes.
File renamed without changes.
72 changes: 0 additions & 72 deletions GoogleSignInPlugin/Assets/GoogleSignIn/GoogleSignInStatusCode.cs

This file was deleted.

9 changes: 0 additions & 9 deletions GoogleSignInPlugin/Assets/Parse.meta

This file was deleted.

30 changes: 0 additions & 30 deletions GoogleSignInPlugin/Assets/Parse/LICENSE

This file was deleted.

9 changes: 0 additions & 9 deletions GoogleSignInPlugin/Assets/Parse/Plugins.meta

This file was deleted.

Binary file not shown.
36 changes: 0 additions & 36 deletions GoogleSignInPlugin/Assets/Parse/Plugins/Unity.Compat.dll.meta

This file was deleted.

Binary file not shown.
36 changes: 0 additions & 36 deletions GoogleSignInPlugin/Assets/Parse/Plugins/Unity.Tasks.dll.meta

This file was deleted.

Loading

0 comments on commit 08010fc

Please sign in to comment.