Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent migration attempt #3

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f453f6c
remove native google signin
Thaina Oct 9, 2023
57a9a9a
UPM package + Update pod version
Thaina Oct 10, 2023
2640b94
add reflection path for older version of unity
Thaina Oct 19, 2023
62ac175
Update GoogleSignInImpl.cs
Thaina Nov 9, 2023
9aa40ab
Update GoogleSignInImpl.cs
Thaina Nov 25, 2023
bff1079
add timeout to await for silentSignIn
Thaina Dec 13, 2023
aea1435
change return status value
Thaina Dec 13, 2023
113f889
Clean Up + Fixes
calumma-robert Mar 12, 2024
8bc535a
Fixes
calumma-robert Mar 12, 2024
a402de9
Version bump
calumma-robert Mar 12, 2024
b6a161a
Fixes
calumma-robert Mar 12, 2024
9d4350d
No additional wait
calumma-robert Mar 12, 2024
f5404e4
Update Future.cs
calumma-robert Mar 13, 2024
f7c807e
Update package.json
Thaina Mar 13, 2024
65c9f13
Merge pull request #4 from calumma-robert/master
Thaina Mar 13, 2024
1c4a52e
Update GoogleSignIn.cs
Thaina Jun 4, 2024
64f17b3
Migrate android to CredentialManager
Thaina Jun 10, 2024
d7915e1
always set webclientId
Thaina Jun 12, 2024
76d2985
fix serverAuthCode in ios
Thaina Jun 13, 2024
f5e644c
Update README.md, credit the source of the fix
Thaina Jun 26, 2024
c1e737f
Add GetSignInWithGoogleOption for sign in manually flow
Thaina Jun 29, 2024
17b3fb4
Convert java API to be static, as instance API will not let us signIn…
Thaina Jun 29, 2024
d4752b8
Fix auto signin
Thaina Jul 13, 2024
f7eab29
Fix SignInSilentlyAsync
Thaina Aug 15, 2024
cdb93a3
add log with INTERNAL_ERROR
Thaina Aug 15, 2024
b2eeeea
Replace URL-safe characters and fix padding
harunayyildizhadi Sep 27, 2024
4614570
Merge pull request #20 from HadiTeam/bugfix/google_sign_in_get_user_id
Thaina Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**/.DS_Store

.gradle/
.idea/
.vscode/
bin/
build/
*.iml
Expand Down
55 changes: 55 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.gitmodules": true,
"**/*.booproj": true,
"**/*.pidb": true,
"**/*.suo": true,
"**/*.user": true,
"**/*.userprefs": true,
"**/*.unityproj": true,
"**/*.dll": true,
"**/*.exe": true,
"**/*.pdf": true,
"**/*.mid": true,
"**/*.midi": true,
"**/*.wav": true,
"**/*.gif": true,
"**/*.ico": true,
"**/*.jpg": true,
"**/*.jpeg": true,
"**/*.png": true,
"**/*.psd": true,
"**/*.tga": true,
"**/*.tif": true,
"**/*.tiff": true,
"**/*.3ds": true,
"**/*.3DS": true,
"**/*.fbx": true,
"**/*.FBX": true,
"**/*.lxo": true,
"**/*.LXO": true,
"**/*.ma": true,
"**/*.MA": true,
"**/*.obj": true,
"**/*.OBJ": true,
"**/*.asset": true,
"**/*.cubemap": true,
"**/*.flare": true,
"**/*.mat": true,
"**/*.meta": true,
"**/*.prefab": true,
"**/*.unity": true,
"build/": true,
"Build/": true,
"Library/": true,
"library/": true,
"obj/": true,
"Obj/": true,
"ProjectSettings/": true,
"temp/": true,
"Temp/": true
},
"dotnet.defaultSolution": "TestGoogleSignIn.sln"
}

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

4 changes: 1 addition & 3 deletions ...ets/GoogleSignIn/Editor/m2repository.meta → Editor.meta

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

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

21 changes: 21 additions & 0 deletions Editor/iOS/PListImporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#if UNITY_EDITOR
using System.IO;

using UnityEngine;

using UnityEditor.AssetImporters;

[ScriptedImporter(1, "plist")]
public class PListImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
{
if(ctx.mainObject is TextAsset)
return;

var subAsset = new TextAsset(File.ReadAllText(ctx.assetPath));
ctx.AddObjectToAsset("text", subAsset);
ctx.SetMainObject(subAsset);
}
}
#endif
11 changes: 11 additions & 0 deletions Editor/iOS/PListImporter.cs.meta

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

67 changes: 67 additions & 0 deletions Editor/iOS/PListProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#if UNITY_EDITOR
using UnityEngine;

using UnityEditor;
using UnityEditor.iOS.Xcode;

using UnityEditor.Build;
using UnityEditor.Build.Reporting;

using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class PListProcessor : IPostprocessBuildWithReport
{
public int callbackOrder => 99999;

public void OnPostprocessBuild(BuildReport report)
{
#if UNITY_IOS
string projectBundleId = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS);
var plistFiles = AssetDatabase.FindAssets("glob:\"**/*.plist\"").Select((guid) => {
var doc = new PlistDocument();
doc.ReadFromFile(AssetDatabase.GUIDToAssetPath(guid));
return doc;
}).Where((doc) => {
return doc.root.values.TryGetValue("BUNDLE_ID",out var element) && element.AsString() == projectBundleId;
}).ToArray();

if(!(plistFiles?.Length > 0))
return;

var google = plistFiles.FirstOrDefault();

if(!(google.root.values.TryGetValue("CLIENT_ID",out var CLIENT_ID) && CLIENT_ID?.AsString() is string clientID && clientID.EndsWith("googleusercontent.com")))
throw new KeyNotFoundException("CLIENT_ID");
if(!(google.root.values.TryGetValue("REVERSED_CLIENT_ID",out var REVERSED_CLIENT_ID) && REVERSED_CLIENT_ID?.AsString() is string reversedClientID && reversedClientID.StartsWith("com.googleusercontent")))
throw new KeyNotFoundException("REVERSED_CLIENT_ID");

string plistPath = Path.Combine( report.summary.outputPath, "Info.plist" );

var info = new PlistDocument();
info.ReadFromFile(plistPath);

info.root.SetString("GIDClientID",clientID);
var CFBundleURLTypes = (info.root.values.TryGetValue("CFBundleURLTypes",out var element) ? element.AsArray() : null) ?? info.root.CreateArray("CFBundleURLTypes");
if(!(CFBundleURLTypes?.values?.Count > 0 && CFBundleURLTypes.values.OfType<PlistElementDict>().Select((dict) => dict.values.TryGetValue("CFBundleURLSchemes",out var value) ? value?.AsArray() : null).OfType<PlistElementArray>().SelectMany((array) => array.values).Any((item) => item?.AsString() == reversedClientID)))
{
var dict = CFBundleURLTypes.AddDict();
dict.SetString("CFBundleTypeRole","Editor");
dict.CreateArray("CFBundleURLSchemes").AddString(reversedClientID);
}

if(google.root.values.TryGetValue("WEB_CLIENT_ID",out var WEB_CLIENT_ID) && WEB_CLIENT_ID?.AsString() is string webClientID && !string.IsNullOrWhiteSpace(webClientID))
{
if(webClientID.EndsWith("googleusercontent.com"))
info.root.SetString("GIDServerClientID",webClientID);
else throw new ArgumentException("WebClientID");
}

info.WriteToFile(plistPath);
#endif
}
}

#endif
11 changes: 11 additions & 0 deletions Editor/iOS/PListProcessor.cs.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 @@ -3,17 +3,14 @@
<!-- See https://github.com/googlesamples/unity-jar-resolver#usage for
how to configure dependencies -->
<androidPackages>
<androidPackage spec="com.google.android.gms:play-services-auth:20+">
<androidSdkPackageIds>
<androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
</androidSdkPackageIds>
</androidPackage>
<androidPackage spec="androidx.credentials:credentials:1.2.2" />
<androidPackage spec="androidx.credentials:credentials-play-services-auth:1.2.2" />
<androidPackage spec="com.google.android.libraries.identity.googleid:googleid:1.1.0" />
<androidPackage spec="com.google.android.gms:play-services-auth:21.2.0" />
</androidPackages>

<!-- iOS Cocoapod dependencies can be specified by each iosPod element. -->
<iosPods>
<iosPod name="GoogleSignIn" version=">= 6.0.2" bitcodeEnabled="false"
minTargetSdk="6.0">
</iosPod>
<iosPod name="GoogleSignIn" version="~> 7.1.0" bitcodeEnabled="false" />
</iosPods>
</dependencies>

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

Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.aar
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.aar.md5
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.aar.sha1
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.pom
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.pom.md5
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.pom.sha1
Assets/GoogleSignIn/Future.cs
Assets/GoogleSignIn/GoogleSignIn.cs
Assets/GoogleSignIn/GoogleSignInConfiguration.cs
Assets/GoogleSignIn/GoogleSignInStatusCode.cs
Assets/GoogleSignIn/GoogleSignInUser.cs
Assets/GoogleSignIn/Impl/BaseObject.cs
Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs
Assets/GoogleSignIn/Impl/NativeFuture.cs
Assets/GoogleSignIn/Impl/SignInHelperObject.cs
Assets/PlayServicesResolver/Editor/Google.VersionHandlerImpl_v1.2.89.0.dll
Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.89.0.dll
Assets/PlayServicesResolver/Editor/Google.VersionHandler.dll
Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.89.0.dll
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.h
Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h
Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm
Assets/Parse/LICENSE
Assets/Parse/Plugins/Unity.Compat.dll
Assets/Parse/Plugins/Unity.Tasks.dll
Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.54.0.dll
Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.54.0.dll
Assets/PlayServicesResolver/Editor/Google.VersionHandler.dll
Assets/PlayServicesResolver/Editor/Google.VersionHandlerImpl_v1.2.54.0.dll
Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.54.0.txt
Assets/Plugins/Android/native-googlesignin-release.aar
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.h
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm
Assets/SignInSample/MainScene.unity
Assets/SignInSample/SigninSampleScript.cs
Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs
Assets/GoogleSignIn/Impl/SignInHelperObject.cs
Assets/GoogleSignIn/Impl/NativeFuture.cs
Assets/GoogleSignIn/Impl/BaseObject.cs
Assets/GoogleSignIn/GoogleSignIn.cs
Assets/GoogleSignIn/GoogleSignInConfiguration.cs
Assets/GoogleSignIn/Future.cs
Assets/GoogleSignIn/GoogleSignInUser.cs
Assets/GoogleSignIn/GoogleSignInStatusCode.cs
Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml
Assets/GoogleSignIn/Editor/GoogleSignInSupportDependencies.xml
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/maven-metadata.xml
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/maven-metadata.xml.md5
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/maven-metadata.xml.sha1
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom.md5
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.srcaar.sha1
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom.sha1
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.srcaar
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.srcaar.md5

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

Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ internal Future(FutureAPIImpl<T> impl) {
/// Gets the status.
/// </summary>
/// <value>The status is set when Pending == false.</value>
GoogleSignInStatusCode Status { get { return apiImpl.Status; } }
public GoogleSignInStatusCode Status { get { return apiImpl.Status; } }

/// <summary>
/// Gets the result.
/// </summary>
/// <value>The result is set when Pending == false and there is no error.
/// </value>
T Result { get { return apiImpl.Result; } }
public T Result { get { return apiImpl.Result; } }

/// <summary>
/// Waits for result then completes the TaskCompleationSource.
Expand All @@ -71,14 +71,29 @@ 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) {
yield return null;
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));
}
}

internal async Task WaitForResultAsync(TaskCompletionSource<T> tcs)
{
while (Pending) await Task.Yield();
await Task.Yield();
if (Status == GoogleSignInStatusCode.CANCELED) {
tcs.SetCanceled();
} else if (Status == GoogleSignInStatusCode.SUCCESS ||
Status == GoogleSignInStatusCode.SUCCESS_CACHE) {
tcs.SetResult(Result);
} else {
tcs.SetException(new GoogleSignIn.SignInException(Status));
}
}
}
}
}

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

Loading