How to create binding to object.object.function? (gapi.auth2.getAuthInstance) #3543
-
How To create binding to object.object.function? (gapi.auth2.getAuthInstance) I have this code in js: function signInWithGoogle() {
const auth2 = gapi.auth2.getAuthInstance();
auth2.signIn().then(function(googleUser) {
// Usa getAuthResponse() para obtener el token de acceso, ID, etc.
const authResponse = googleUser.getAuthResponse();
console.log('Access token:', authResponse.access_token);
console.log('ID token:', authResponse.id_token);
}, function(error) {
console.error('Error during sign-in:', error);
});
} But I want to develop it entirely in Rust. How do I do this in wasm-bindgen? |
Beta Was this translation helpful? Give feedback.
Answered by
Liamolucko
Aug 3, 2023
Replies: 1 comment
-
Assuming that use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
type Auth2;
#[wasm_bindgen(js_namespace = ["gapi", "auth2"], js_name = "getAuthInstance")]
fn get_auth_instance() -> Auth2;
} Calling |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Miuler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming that
gapi
is a global variable, you can usejs_namespace
to do that:Calling
get_auth_instance
will then callgapi.auth2.getAuthInstance()
.