Facebook sdk can only login either with read permission or publish permission, but what if I want both? I only need read permission when logging in to register a user or to authenticate it.
So I thought the right way was to first signIn with SignInMode.READ and then signIn again but now with SignInMode.PUBLISH
The problem is when I try to sign in the second time, it just load the accessToken, I tried to put facebook.signOut() in between but nothing...
facebook.signIn(SignInMode.READ, readPermissions, new GDXFacebookCallback<SignInResult>() {
#Override
public void onSuccess(SignInResult result) {
// Login successful
clientManager.login(result.getAccessToken().getToken());
}
#Override
public void onError(GDXFacebookError error) {
// Error handling
}
#Override
public void onCancel() {
}
#Override
public void onFail(Throwable t) {
}
});
//after the user log ins, the app ask for publish permissions, and I
// try to get it by logging in again but now wit `SignInMode.PUBLISH` like so....
facebook.signIn(SignInMode.PUBLISH, publishPermissions, new GDXFacebookCallback<SignInResult>() {
#Override
public void onSuccess(SignInResult result) {
// Login successful
clientManager.login(result.getAccessToken().getToken());
}
#Override
public void onError(GDXFacebookError error) {
// Error handling
}
#Override
public void onCancel() {
}
#Override
public void onFail(Throwable t) {
}
});
What im trying to ask here is how I get an accessToken capable of publishing after I singin with SignInMode.READ?
I am the developer of gdx-facebook extension.
You are doing it correctly, sign in with read permissions first and then follow with publish permission.
There are 2 cases:
You did not authorize the app yet or did authorize the app with less permissions than the ones you request.
-> you get a new token, which contains all existing and newly requested permissions. All existing tokens become invalid.
You already have granted all the requested permissions.
-> you get the latest token.
What im trying to ask here is how I get an accessToken capable of
publishing after I singin with SignInMode.READ?
Just request the permission you need, you get either a new upgraded token which contains old and new permissions or an old one which already contains the permissions.
It is likely that you already granted the permissions and thats why the token does not change. Look in your FB settings -> apps to see which permissions you granted.
Tokens often look similar the first 10-20 characters. Don't get confused by that.
Related
I am using Firebase oAuthProvider to authenticate the user with Microsoft.
OAuthProvider.Builder provider = OAuthProvider.newBuilder("microsoft.com");
provider.addCustomParameter("prompt", "consent");
firebaseAuth
.startActivityForSignInWithProvider(/* activity= */ this, provider.build())
.addOnSuccessListener(
new OnSuccessListener<AuthResult>() {
#Override
public void onSuccess(AuthResult authResult) {
// User is signed in.
// IdP data available in
// authResult.getAdditionalUserInfo().getProfile().
// The OAuth access token can also be retrieved:
// authResult.getCredential().getAccessToken().
// The OAuth ID token can also be retrieved:
// authResult.getCredential().getIdToken().
}
})
.addOnFailureListener(
new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
// Handle failure.
}
});
When the oAuth is launched, it opens a chrome tab, the problem arises if Microsoft requires 2 factor and user switches from the web view and opens another app like gmail or messages, the webview disappears and seems like it cant be accessed again. Is there a way to make sure that the chrome tab is not closed when switching out of the chrome tab?
I'm new with zoom integration.
I wants user login and create meeting in their account. I've done login user part using loginWithZoom method but now wants to create meeting for that auth token needed.
How can I get token when user login in zoom without OAuth?
I've found but not getting much idea. I tried with JWT token it works with
https://api.zoom.us/v2/users/me/meetings api. I gave Authorization token and content-type in
headers. it gives me all meetings of that specific user. but problem to get different authorization token for different users. I don't have idea is it possible or not.
Suggest if anyone knows
Code I've used for Login:
public void initializeSdk(Context context) {
ZoomSDK sdk = ZoomSDK.getInstance();
// TODO: Do not use hard-coded values for your key/secret in your app in production!
ZoomSDKInitParams params = new ZoomSDKInitParams();
params.appKey = "a...t4.."; // TODO: Retrieve your SDK key and enter it here
params.appSecret = "y...19"; // TODO: Retrieve your SDK secret and enter it here
params.domain = "zoom.us";
params.enableLog = true;
// TODO: Add functionality to this listener (e.g. logs for debugging)
ZoomSDKInitializeListener listener = new ZoomSDKInitializeListener() {
/**
* #param errorCode {#link us.zoom.sdk.ZoomError#ZOOM_ERROR_SUCCESS} if the SDK has been initialized successfully.
*/
#Override
public void onZoomSDKInitializeResult(int errorCode, int internalErrorCode) {
Log.i("","onZoomSDKInitializeResult Error code"+errorCode);
Toast.makeText(getApplicationContext()," error code : " + errorCode,Toast.LENGTH_LONG).show();
}
#Override
public void onZoomAuthIdentityExpired() {
System.out.println(" identity expired..");
}
};
sdk.initialize(context, listener, params);
}
findViewById(R.id.login_button).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "onclick of login", Toast.LENGTH_LONG).show();
Log.i(" ","onclick of login : "+ ZoomSDK.getInstance().isLoggedIn());
if (ZoomSDK.getInstance().isLoggedIn()) {
//wants to create meeting
} else {
createLoginDialog();
}
}
});
private void createLoginDialog() {
new AlertDialog.Builder(this)
.setView(R.layout.dialog_login)
.setPositiveButton("Log in", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
AlertDialog dialog = (AlertDialog) dialogInterface;
TextInputEditText emailInput = dialog.findViewById(R.id.email_input);
TextInputEditText passwordInput = dialog.findViewById(R.id.pw_input);
if (emailInput != null && emailInput.getText() != null && passwordInput != null && passwordInput.getText() != null) {
String email = emailInput.getText().toString();
String password = passwordInput.getText().toString();
if (email.trim().length() > 0 && password.trim().length() > 0) {
login(email, password);
}
}
dialog.dismiss();
}
})
.show();
}
public void login(String username, String password) {
int result = ZoomSDK.getInstance().loginWithZoom(username, password);
if (result == ZoomApiError.ZOOM_API_ERROR_SUCCESS) {
// Request executed, listen for result to start meeting
ZoomSDK.getInstance().addAuthenticationListener(authListener);
}
}
public void onZoomSDKLoginResult(long result) {
if (result == ZoomAuthenticationError.ZOOM_AUTH_ERROR_SUCCESS) {
// Once we verify that the request was successful, we may start the meeting
Toast.makeText(getApplicationContext(), "Login successfully", Toast.LENGTH_SHORT).show();
} else if(result == ZoomAuthenticationError.ZOOM_AUTH_ERROR_USER_NOT_EXIST || result == ZoomAuthenticationError.ZOOM_AUTH_ERROR_WRONG_PASSWORD){
Toast.makeText(getApplicationContext(),"Invalid username or password",Toast.LENGTH_LONG).show();
}
}
Thanks in advance.
I tried with JWT token it works with
https://api.zoom.us/v2/users/me/meetings api. I gave Authorization
token and content-type in headers. it gives me all meetings of that
specific user. but problem to get different authorization token for
different users. I don't have idea is it possible or not.
Assuming these users are not part of the same Zoom account, then no, it is not possible as of 2021-08-28. JWT-based authentication is only for Zoom integration in internal applications/services:
Note: JWT may only be used for internal applications and processes. All apps created for third-party usage must use our OAuth app type.
In this context, "internal" means "only to be used with a single Zoom account." Note that there can be many users under one account (e.g., all employees of Corporation XYZ are part of XYZ's Zoom account). Put differently, you can use a JWT issued for the XYZ Zoom account to access information for all users under the XYZ Zoom account, but if you need data for users that are not part of the XYZ Zoom account, then you need an API Key and API Secret for their Zoom account(s) as well to generate JWTs that you can use to retrieve their data.
If you are building an integration/service that you want to make available to the general public, then you need to use OAuth:
This app can either be installed and managed across an account by
account admins (account-level app) or by users individually
(user-managed app).
I followed the guide on the Android docs but for some reason nothing is showing when i start my app.
I even tried logging the listeners but nothing is showing up in logcat.
I also changed the ad technology in admob setting to Custom set of ad technology providers, but still not working.
My code
ConsentInformation consentInformation = ConsentInformation.getInstance(getApplicationContext());
ConsentInformation.getInstance(getApplicationContext()).addTestDevice("6AE7D8950FE9E464D988F340C0D625B0");
ConsentInformation.getInstance(getApplicationContext()).
setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA);
String[] publisherIds = {""};
consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
#Override
public void onConsentInfoUpdated(ConsentStatus consentStatus) {
// User's consent status successfully updated.
Log.d(TAG,"onConsentInfoUpdated");
}
#Override
public void onFailedToUpdateConsentInfo(String errorDescription) {
// User's consent status failed to update.
Log.d(TAG,"onFailedToUpdateConsentInfo");
}
});
form = new ConsentForm.Builder(this, privacyUrl)
.withListener(new ConsentFormListener() {
#Override
public void onConsentFormLoaded() {
// Consent form loaded successfully.
Log.d(TAG,"form loaded!");
form.show();
}
#Override
public void onConsentFormOpened() {
// Consent form was displayed.
}
#Override
public void onConsentFormClosed(
ConsentStatus consentStatus, Boolean userPrefersAdFree) {
// Consent form was closed.
}
#Override
public void onConsentFormError(String errorDescription) {
// Consent form error.
Log.d(TAG,"form error!");
}
})
.withPersonalizedAdsOption()
.withNonPersonalizedAdsOption()
.withAdFreeOption()
.build();
form.load();
Gradle
dependencies {
classpath 'com.google.gms:google-services:4.3.2'
}
implementation 'com.google.android.ads.consent:consent-library:1.0.7'
implementation 'com.google.android.gms:play-services-plus:17.0.0'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
EDIT
I tried it on a project which was pre android x and now it calls the listener onFailedToUpdateConsentInfo.
With following error message:
onFailedToUpdateConsentInfoCould not parse Event FE preflight response.
Searched a bit and found this could be because of an invalid pub id, but i'm certain i'm using the right one.
1) I think you forget to check isRequestLocationInEeaOrUnknown() method.
It will return true If user already agreed to the consent. In this case, you don't need to ask it again. I think you already agreed to consent.
wrap your code with
if(ConsentInformation.getInstance(context).isRequestLocationInEeaOrUnknown()){
//setup admob
}else{
//Ask for consent
}
2) You have to call form.show(); to present the form to the user, check Google Doc
I was still using test app id and test ad ids, remove them and change it with your id's and make sure you use it as a testdevice so you don't violate admob policies.
Like this
adLoader.loadAd(new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build());
So I know I can use email verification, or phone number verification, but what I want to do is a phone number verification after the user has registered or logged in. How do you connect this these two authentication methods. Finally, is there a function in Firebase to check if the user is verified by phone number or not? Thank you.
You can still use the APi provided by firebase to verify the number even if the user is authenticated. According to the docs , the authentication happens only when the user receives the confirmation code and generates a PhoneAuthCredential. If you just want to vrify the phone you can simply provide a custom reaction to the callback onVerificationCompleted.
Normally you set up the provider:
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber,
60,
TimeUnit.SECONDS,
this,
mCallbacks);
And you implement a series of callbacks.
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
//No need to authenticate again, just react to verified number
//signInWithPhoneAuthCredential(credential);
}
#Override
public void onVerificationFailed(FirebaseException e) {
if (e instanceof FirebaseAuthInvalidCredentialsException) {
} else if (e instanceof FirebaseTooManyRequestsException) {
}
}
#Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
mVerificationId = verificationId;
mResendToken = token;
}
};
According to your second question about to verify how the user is signed in you can check this answer to see how to check the firebase user authentication providers.
When a user is logged in you can get its phone number (if there is any) by calling:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String number = user.getPhoneNumber();
I press a custom button to let the user give publish permissions to my Android app(Facebook SDK 4.18.0). It works. It goes to the facebook fragment in which prompts the user to give publish permissions to the app and then it comes back to the activity in which the button was pressed. The thing is that I've run the debugger and it never goes through the callback functions which I need to do what I need to do after the user has accepted.
The listener:
permissionButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
permissionButton.startAnimation(rotation);
JSONObject userCredentials = new JSONObject();
//ask for facebook publishing permissions
if(facebook_connected) {
CallbackManager callbackManager = CallbackManager.Factory.create();
facebookLoginWithPublishPermissions(callbackManager);
}
}
});
And my custom function 'facebookLoginWithPublishPermissions' which intends to get a token with publish permissions(do I need a new one or the old one works now that I've been granted the "publish_actions" permissions for this user, cause I'm already logged in and have the access_token but only with the basic permissions using firebase ui auth module for android)? If I go to the facebook page of the user I can see that the proper permissions has been set so everything OK regarding that. The code:
private void facebookLoginWithPublishPermissions(CallbackManager callbackManager) {
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
Log.d("FACEBOOK_LOGIN_RESULT", "facebook login success");
Log.d("LOGIN_RESULT", loginResult.getAccessToken().getToken());
}
#Override
public void onCancel() {
Log.d("FACEBOOK_LOGIN_RESULT", "facebook login canceled");
}
#Override
public void onError(FacebookException exception) {
Log.e("FACEBOOK_LOGIN_RESULT", "facebook login error");
exception.printStackTrace();
}
});
LoginManager.getInstance().logInWithPublishPermissions((Activity) mContext, Arrays.asList("publish_actions"));
}
1-How can I get a new token(in case is need to renew the token if you ask for additional permissions)?
2-How can I make the callback function work to perform actions after the publish_actions permission has been granted??
Thank you very much for your help!
EDIT: For future reference regarding Facebook API/Permission politics, Facebook provides a DIFFERENT Token from the one you are first provided when you login with the basic permissions. They have to review your app to see if you are using the permissions ONLY when you need it and also to check if you are not asking those permissions "just in case" to avoid unnecessary requests to their server. Also they want to make sure that you let the user know what's happening, they must accept the publishing permission, that's why you have to do 2 requests, first the read permissions the first time you connect to facebook, and a second request for writing(publish_actions) permissions. You CANNOT ask for publishing permissions unless you already asked for reading permissions first....
Are you adding the following method to your code ?
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
Log.d("TAG: 5. ", "I´m at onActivity result");
}