xamarin / google-apis Goto Github PK
View Code? Open in Web Editor NEWGoogle API bindings for Xamarin.
License: Apache License 2.0
Google API bindings for Xamarin.
License: Apache License 2.0
How i can refresh the token when expired? I want to show the login UI only the first time the user access.
my solution if is ok:
var attributes = property.GetCustomAttributes<Google.Apis.Util.RequestParameterAttribute>();
if (attributes != null && attributes.Count() > 0)
{
var attribute = attributes.ElementAt (0);
string name = attribute.Name ?? property.Name.ToLower();
object valueObject = property.GetValue(this, new object[] {} );
string value = String.Empty;
if (valueObject != null)
{
value = valueObject.ToString();
}
requestBuilder.AddParameter(attribute.Type, name, value);
}
My SignIn method is as follows:
public void SignIn()
{
Debug.WriteLine("In SignIn");
if (GdAuthenticator == null)
{
(App.GdClientId, App.GdRedirectUrl, App.GdClientSecret) = App.SetIDs4GoogleDrive();
Debug.WriteLine($"GdRedirectUrl: {App.GdRedirectUrl}");
GdAuthenticator = new OAuth2Authenticator(
App.GdClientId,
App.GdClientSecret,
App.GdScope,
new Uri("https://accounts.google.com/o/oauth2/v2/auth"),
new Uri(App.GdRedirectUrl),
new Uri("https://www.googleapis.com/oauth2/v4/token"),
isUsingNativeUI: true);
GdAuthenticator.Completed += Auth_Completed;
AuthenticatorHelper.OAuth2Authenticator = GdAuthenticator;
}
// This flag is set here as for iOS, AppDelegate.OpenUrl is invoked even before
// this.Auth_Completed event is invoked and this flag is needed to redirect
// to this app after authentication
if (Device.RuntimePlatform == Device.iOS)
App.StorageServiceSignedIn = App.StorageServices.GoogleDrive;
OAuthLoginPresenter presenter = new OAuthLoginPresenter();
presenter.Login(GdAuthenticator);
}
GdScope is set as follows:
public static string GdScope = "https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file";
The error occuring is:
System.UnauthorizedAccessException
Message=Access to the path '/private/var/mobile/Containers/Data/Application/FE509305-6324-4705-B517-DA2A98B18A69/.local/share/google-filedatastore/Google.Apis.Auth' is denied.
I don't find any line containing "FE5" in the device logs.
The Publishing Status of my app on Google API site is "Testing".
Since it is not failing on the simulator I assume that all authentications are in order. The app is run on iPhone 6 in Debug mode.
I published the app to App Store after testing in Debug mode but never tested on device in Release mode. But I found the issue after users facing crash issue while signing into Google Drive services that I am using in the app.
Let me know if you need any further info.
ThanQ...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.