本文整理汇总了Java中com.google.android.gms.auth.api.Auth类的典型用法代码示例。如果您正苦于以下问题:Java Auth类的具体用法?Java Auth怎么用?Java Auth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Auth类属于com.google.android.gms.auth.api包,在下文中一共展示了Auth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LoginGoogle
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
public LoginGoogle(final Context context, SignInButton button, final Activity act, PreferencesShared pref) {
this.context = context;
preferencesShared = pref;
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken("473547758853-nm840bumsu5km04gbgtdee1fhtod1ji6.apps.googleusercontent.com").build();
gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.PLUS_LOGIN)).requestScopes(new Scope(Scopes.PLUS_ME)).requestEmail().requestIdToken("473547758853-nm840bumsu5km04gbgtdee1fhtod1ji6.apps.googleusercontent.com").build();
mGoogleApiClient = new GoogleApiClient.Builder(context.getApplicationContext())
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
button.setSize(SignInButton.SIZE_STANDARD);
button.setScopes(gso.getScopeArray());
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
act.startActivityForResult(signInIntent, 101);
}
});
}
示例2: initGoogleApiClient
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
private void initGoogleApiClient() {
final GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestProfile()
.requestScopes(new Scope(SCOPE_PICASA))
.build();
googleApiClient = new GoogleApiClient.Builder(activity)
.enableAutoManage(activity,
connectionResult -> emitter.onError(new SignInException("Connecting", connectionResult.getErrorMessage(), connectionResult.getErrorCode())))
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(@Nullable Bundle bundle) {
actWhenConnected();
}
@Override
public void onConnectionSuspended(int i) {
}
})
.build();
}
示例3: onClick
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.sign_in_button:
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, 1);
break;
case R.id.sign_out_button:
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
Log.w("credentials","Status: "+ status.getStatus());
Log.w("credentials","StatusMessage: "+ status.getStatusMessage());
}
});
break;
}
}
示例4: handleSignInResult
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
/**
* Handle google sign in result
*
* @param result the GoogleSignInResult result
*/
public void handleSignInResult(final GoogleSignInResult result) {
if (result.isSuccess()) {
GoogleSignInAccount account = result.getSignInAccount();
mGoogleApiClient.disconnect();
verifySmartLockIsEnabled(new RxAccount(account));
}
else {
// delete credential
if(mCredential != null) {
Auth.CredentialsApi.delete(mGoogleApiClient, mCredential).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
mGoogleApiClient.disconnect();
mAccountSubject.onError(new Throwable(result.getStatus().toString()));
}
});
}
else {
mGoogleApiClient.disconnect();
mAccountSubject.onError(new Throwable(result.getStatus().toString()));
}
}
}
示例5: onCreate
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
// Assign fields
mSignInButton = (SignInButton) findViewById(R.id.sign_in_button);
// Set click listeners
mSignInButton.setOnClickListener(this);
// Configure Google Sign In
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
// Initialize FirebaseAuth
}
示例6: onActivityResult
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
} else {
// Google Sign In failed
Log.e(TAG, "Google Sign In failed.");
}
}
}
示例7: login
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void login(@NonNull SmartLoginConfig config) {
GoogleApiClient apiClient = config.getGoogleApiClient();
Activity activity = config.getActivity();
if (apiClient == null) {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestProfile()
.build();
apiClient = new GoogleApiClient.Builder(activity)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
}
ProgressDialog progress = ProgressDialog.show(activity, "", activity.getString(R.string.logging_holder), true);
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(apiClient);
activity.startActivityForResult(signInIntent, Constants.GOOGLE_LOGIN_REQUEST);
progress.dismiss();
}
示例8: onActivityResult
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mCallbackManager.onActivityResult(requestCode, resultCode, data);
twitter.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
} else {
checkconnection();
}
}
}
示例9: onActivityResult
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGNIN_GOOGLE) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount account = result.getSignInAccount();
AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
auth.signInWithCredential(credential)
.addOnCompleteListener(this, this);
} else
onFailure(result.getStatus().toString());
} else
callbackManager.onActivityResult(requestCode, resultCode, data);
}
示例10: setUpGoogleAuth
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
private void setUpGoogleAuth() {
// Configure sign-in to request the user's ID, email address, idToken and basic profile.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.client_id))
.requestEmail()
.build();
// Build a GoogleApiClient with access to the Google Sign-In API and the options specified by gso.
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addApi(AppIndex.API).build();
// Set GoogleApiClient into AppRunnest instance to be used in the rest of the application.
((AppRunnest) getApplication()).setApiClient(googleApiClient);
}
示例11: pluginInitialize
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
protected void pluginInitialize() {
Log.d(TAG, "Starting Firebase Authentication plugin");
this.firebaseAuth = FirebaseAuth.getInstance();
this.phoneAuthProvider = PhoneAuthProvider.getInstance();
Context context = this.cordova.getActivity().getApplicationContext();
String defaultClientId = getDefaultClientId(context);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(defaultClientId)
.requestEmail()
.requestProfile()
.build();
googleApiClient = new GoogleApiClient.Builder(context)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
googleApiClient.connect();
//firebaseAuth = FirebaseAuth.getInstance();
//firebaseAuth.addAuthStateListener(this);
}
开发者ID:kanodeveloper,项目名称:cordova-plugin-firebase-performance-ka,代码行数:23,代码来源:FirebaseAuthenticationPlugin.java
示例12: onActivityResult
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == Utils.FIREBASE_GOOGLE_SIGN_IN) {
GoogleSignInResult result =
Auth.GoogleSignInApi.getSignInResultFromIntent(data);
isIntentInProgress = false;
if (!mGoogleApiClient.isConnecting()) { mGoogleApiClient.connect(); }
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
} else {
// Google Sign In failed, update UI appropriately
// updateUI(null);
}
}
}
示例13: signOut
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
protected void signOut(GoogleApiClient googleApiClient){
mAuth.signOut();
Auth.GoogleSignInApi.signOut(googleApiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
Toast toast = Toast.makeText(AuthBaseActivity.this,
mResources.getString(R.string.sign_out_text),
Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 100);
toast.show();
Intent i = new Intent(AuthBaseActivity.this, SignInActivity.class);
AuthBaseActivity.this.startActivity(i);
AuthBaseActivity.this.finish();
}
});
}
示例14: onActivityResult
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
setSessionManagement();
firebaseAuthWithGoogle(account);
} else {
// Google Sign In failed, update UI appropriately
// ...
}
}
}
示例15: onActivityResult
import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == CRDConstants.REQUEST_CODE_GOOGLE_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
logInToFirebaseWithGoogleSignIn(account);
} else {
Log.e(CRDAuthActivity.class.getName(), "onActivityResult().REQUEST_CODE_GOOGLE_SIGN_IN FAILED ! " + "getSignInResultFromIntent = [" + result.getStatus() + "]");
}
}
}