Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea
Accepted Solution

autofill login credentials in webview

Helo all,

I want to programmatically autofill the username and password feilds of gmail in my webview...

Any help would be appreciable...

 

Thanks & regards

Developer
Posts: 26
Registered: ‎10-05-2013
My Device: Z10
My Carrier: ?

Re: autofill login credentials in webview

settings.credentialAutoFillEnabled: true
Developer
Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: autofill login credentials in webview

yes but i guess this will just allow me to autofill the webpage...but will not directly autofill te webpage through my code..

Im looking for some script to implement in my code that will directly autofill the webpage on loading...

 

Thanks

Developer
Posts: 21
Registered: ‎02-13-2014
My Device: Z10 STL-003
My Carrier: AT&T

Re: autofill login credentials in webview

One option you have is to use Javascript injection, however this is not the most secure way to handle passwords

 

But the results work.

 

The basic code is:

          WebView {
                id: webview
                url: "https://mail.google.com/"
                settings.webInspectorEnabled: true
                onLoadingChanged: {
                    if (title == "Gmail"){
                        var Email = "Email";
                        var Passwd = "Password"
                        var inject = "document.getElementById('Email').value = \""+Email+"\";"+
                        "document.getElementById('Passwd').value = \""+Passwd+"\";";
                        webview.evaluateJavaScript(inject);
                    }
                }
            }

 To rember the password and username I suppose you could use QSettings... but again... security.

 

Good Luck.

Developer
Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: autofill login credentials in webview

cn we similarly implement autologin with the same code..That is can we directly login to the email account..

Like by finding the id of submit button and giving a click event to it

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: autofill login credentials in webview

@JoeQXS Nice answer, but there should be no problem using QSettings from a security perspective the data is saved as an ini file within your own app and cannot be accessed by anything but the app.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 21
Registered: ‎02-13-2014
My Device: Z10 STL-003
My Carrier: AT&T

Re: autofill login credentials in webview

I was referring to how the webview would send the password to every site with 'Gmail' as the title. I'm sure there could be stricter filters, but onLoadingChange is the only way I know to send the injection on page load.

 

And yes, you can trigger the submit button with javascript as well. I'll grab the code for you later today if you want. 

Developer
Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: autofill login credentials in webview

ya that would be really great to get submit button code...Thanks

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: autofill login credentials in webview

Ok fair enough, thanks for the clarification.

If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Highlighted
Developer
Posts: 21
Registered: ‎02-13-2014
My Device: Z10 STL-003
My Carrier: AT&T

Re: autofill login credentials in webview

[ Edited ]

Sorry, long monday...

 

Here you go.

            WebView {
                id: webview
                url: "https://mail.google.com/"
                settings.webInspectorEnabled: true
                onLoadingChanged: {
                    if (title == "Gmail"){
                        var Email = "Email";
                        var Passwd = "Password"
                        var inject = "document.getElementById('Email').value = \""+Email+"\";"+
                        "document.getElementById('Passwd').value = \""+Passwd+"\";"+
                        "document.getElementById('signIn').click();";
                        webview.evaluateJavaScript(inject);
                    }
                }
            }

 Cheers Smiley Happy