Get 403: Forbidden of Google API - encoding problems in my POST?

Hi all

I have problems connecting to the Google API by MAIL by following the instructions on this page:
http://code.Google.com/APIs/accounts/docs/AuthForInstalledApps.html#ClientLogin

I've also posted on the forums of the Google API, but I'm starting to wonder if it's a problem that this forum would be able to answer. Here is the post on the Google forum:
http://www.Google.com/support/forum/p/Apps-APIs/thread?FID=1c22cb44eb5cbba600048a1fc5f25621&hl=en

Google used to accept a GET request and provide a string SID, who served as a connection key services such as Docs and Calendar. He still offers this SID to GET requests, so I know I can do the BB Simulator applications, but it no longer accepts the SID as a connection key. Now, I have to send a POST request in encoding UTF-8, including parameters as my user name and password and get an AUTH token in response.

Missions in this forum, I see that I can use a URLEncodedPostData object to encode the parameters for the WORK in UTF - 8. (I know I have to eventually get keys to use on a true signature BB, but I want to get a hello-world working on the Simulator before I pony up for them). I put the settings in this item and include it in the application, but I always get a 403: forbidden with an error message 'error = BadAuthentication' in response, as if my password is wrong. I checked the name of user and password with care, and I can do the JOB and get the AUTH token with the curvature of the line of control on this machine, there must be something about how I make the POST in the Java code.

Someone on the Google forum suggested that my settings may not have been encoded in UTF - 8, but shouldn't the 'UTF-8' parameter in the constructor URLEncodedPostData manage this coding? I also tried manually escape the '@' in my e-mail address to "% 40" because it seems that URLEncodedPostData does not encode the symbol like this @.» (My password contained no character who must escape for URL encoding.)

Here is the code I use. I use the Eclipse IDE for Blackberry OS 5 (I think that the version of the plugin for eclipse is 5.0.0_5.0.0.25) with Verizon 9630 Tour 5.0.0.591 Simulator. Any help?

private void googleSignInTest(String emailAddress, String googlePassword){

// see http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html#ClientLogin
String uri = "https://www.google.com/accounts/ClientLogin";

InputStream inputStream = null;
HttpsConnection httpsConnection = null;

try{
//create https connection, POST
httpsConnection = (HttpsConnection)Connector.open(uri);
httpsConnection.setRequestMethod(HttpsConnection.POST);

//http://supportforums.blackberry.com/t5/Java-Development/HttpConnection-set-to-POST-does-not-work/m-p...
URLEncodedPostData postData = new URLEncodedPostData("UTF-8", false);
postData.append("accountType", "GOOGLE");
postData.append("Email", emailAddress);
postData.append("Passwd", googlePassword);
postData.append("service", "cl");
postData.append("source", "my-test-app");
postData.append("Content-Type", "application/x-www-form-urlencoded");
postData.append("Content-Language", "en-US");

DataOutputStream outputStream = httpsConnection.openDataOutputStream();
outputStream.write(postData.toString().getBytes());
outputStream.flush();
outputStream.close();

//make the request and get response
int responseCode = httpsConnection.getResponseCode();
//403 Forbidden Error=BadAuthentication

//Do something with the response
...
}catch (IOException e) {
e.printStackTrace();
}

Seems that I have to set the content type in the connection, and not in the post data:

httpsConnection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_TYPE, HttpProtocolConstants.CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);

Also, the following line is probably not just:

outputStream.write(postData.toString().getBytes());

It probably should be:

outputStream.write(postData.getBytes());

Tags: BlackBerry Developers

Similar Questions

  • Firefox only runs very slowly I get "403 forbidden" message whenever I connect. How can I fix it?

    Firefox has turned very slowly on my Mac (version 10.6.8). Very, very slowly. In addition, whenever I connect I get a "403 forbidden" message for my websites favorite, my email, etc. How can I fix it?

    I tried to open Firefox without Add - ons and that did not help at all.

    I also uninstalled MacKeeper, but which did not help either.

    Hello

    I'm glad to hear that your problem has been resolved.

    If you have not already the case, please mark this thread as solved by the solution of marking.

    This will help other users experience similar problems helps to find faster and more efficiently.

    I hope that you will continue using our products and we thank you for contacting the Mozilla Support.

  • Get 403 Forbidden in Firefox, trying to use HELP

    Whenever I try to use the menu of HELP from LR (and other Adobe products), I get a 403 Forbidden message in Firefox my default browser.

    Is the URL which is a failure: http://community.Adobe.com/chcservices/services/redirect?u=http://help.Adobe.com & p = Lightro om_6.0 & l = en & id = AH_HOME

    If I copy and paste this URL in another browser, like IE, the redirect works and resolves at: https://helpx.Adobe.com/Lightroom/topics.html and the help page appears correctly.

    If I then copy this URL resolved in Firefox, the help page then also displays correctly.

    What is causing this problem with Firefox, and how can I solve it?

    Looks like you are running with the LR more up-to-date.

    The reason why we asked for the full version number is 6.0 (2015.0) has been released with a wrong URL in there for help pages and it has been fixed in the updated version first (?).

  • Cannot log on to Twitter. I get 403 Forbidden: the server understood the request, but refuses to fill. »

    When I try to log on to Twitter, I get the error message below.

    403 Forbidden: the server understood the request, but refuses to fill.

    Seems to emerged since I have updated to Firefox... I think so...

    You can manually connect on Twitter by removing cookies from twitter. Click on "Firefox" at the top left, and then choose 'Options '. Click on the "Privacy" tab and click on 'delete cookies '. In the list, scroll down to twitter.com and click on 'Delete the Cookies' I hope this helps. Regarding the 403 error, it is usually caused by a typing error in the address bar, or with a failure on the Twitter servers.

  • Why do I get "403 Forbidden" error when I'm on a 3G connection?

    When I'm on wifi, I don't seem to have this problem. That's what I see on the screen:

    Access denied.

    Technical description:

    403 forbidden - you are not allowed to

    communicate with the requested

    resources.

    It is possible, or the server does not allow mobile browsing.

    Have you tried other browsers (dolphin HD, Miren) to see if the problem

    persists?

    On Friday, 15 July 2011, at 20:56, orlando.terte

  • Get 403 forbidden before I had the opportunity to present the passwords.

    Key URL of a site that I have been on several occasions. Before he even gave me a challenge screen it gives me a 403 Forbidden: access is denied by using the data provided. Works great in IE9.

    How about - https://ghcmychart.com/mychart/ - will it work?

  • has got 403 forbidden Bank sit web... why I'm stuck

    I have an account at the Royal Bank of the Canada, but when I try to access www.rbc.com I get "403 forbidden" why?

    Hello

    Please try after deleting cookies: Tools (Alt + T) > clear recent history, in the interval of time to clear allchoose, click Details and enable (check) the Cookies and clear now. Alternatively, you can also try to selectively delete cookies via Tools > Options > Privacy > Show the Cookies..., type rbc in Search and delete cookies. Also delete cookies from royal.

    Clear recent history

  • I get a 403-Forbidden: access denied message when trying to access my email in Microsoft Outlook Web App

    I use Firefox version with an OS Ubuntu LTS 14.04 33.0. I get a 403-Forbidden: access denied message when trying to access my mail from Microsoft Outlook Web Access (OWA). When I use another computer running version 33.1.1 Firefox with a Windows 7 operating system, I can access my email in Microsoft Outlook Web App perfectly. Anyone have any suggestions on how to get my Firefox browser on the Ubuntu machine to be able to access my email on OWA?

    This problem may be caused by corrupted cookies or cookies that are blocked.

    Clear the cache and delete cookies only from Web sites that cause problems.

    "Clear the Cache":

    • Edit > Preferences > advanced > network > content caching Web: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Edit > Preferences > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem.

    • Put yourself in the DEFAULT theme: Firefox/tools > Modules > appearance
    • Do NOT click on the reset button on the startup window Mode safe
  • How to access a web site without getting a 403 forbidden?

    When I use a PC to access a website to any site the browser takes me to it without any problems. If I should try the same thing on my Mac Mini 2012 the same exact site gives me a 403 Forbidden message. Any browser should I use I get the same results. Why this phenomenon happens and is there a work around?

    On your Mac using Safari go to click menu bar Safari Safari > Preferences then select the Privacy tab, then click: delete all data Web site

    Quit and then restart Safari to test.

    If this does not help, you can have an extension Safari or third party plugin installed which is causing a conflict. It is easy to solve the problems.

    In the Safari menu, click Safari > Preferences , and select the tab ' Extensions '. If there are installed extensions, one at a time uninstall and exit then restart Safari to test.

    If it is not a question of extensions, try troubleshooting third-party plug-ins.

    Back to Safari > Preferences. This time select the tab Security Deselect: plug-ins Allow. Quit and restart Safari to test.

    If it makes a difference, the instructions of troubleshooting plugins here.

  • Get "Server Error 403-Forbidden: access is denied" message when you try to machine client join in Small Business Server 2011 Essentials

    Hi people,
    I recently deployed a Server SBS 2011 Essentials version in our office. We are very please with everything except for one thing. We have an IBM T42 laptop running Win XP Pro SP3 (fully patched) I can not stick to the server.
    Whenever I type the URL to bring up the software of the connector (http://servername/connect), I get a browser message-"Server Error 403-Forbidden: access is denied." You don't have permissio to view this directory or page using the credentials you provided. »
    I can ping the IP address of the server successfully and can navigate to the shared folders on the server without any problem. I also have two Dell laptops that are running Win7 Pro, and I had no problem to join these to the server/domain.
    Any help would be greatly appreciated!

    Hello

    Your question of Windows 7 is more complex than what is generally answered in the Microsoft Answers forums. It is better suited to the TechNet Windows Server Forums. Please post your question in the TechNet forum.

    http://social.technet.Microsoft.com/search/en-us?query=small%20Business%20server%202011&AC=1

  • I can't get rid of "403 forbidden" on my pc how do it e-mail me on _ @_. " ___

    as a novice on a pc, I have this thing called 403 forbidden that comes up all the time, how can I get rid of it

    HELP PLEASE!

    http://www.ehow.com/info_8298974_403-forbidden-error.html

    Read this link, and then follow these steps:

    Download, install, update and do a full scan with these free malware detection programs at:

    Malwarebytes (MMFA): http://malwarebytes.org/

    SUPERAntiSpyware: (SAS): http://www.superantispyware.com/

    http://www.Microsoft.com/security/scanner/en-us/default.aspx Security Scanner   

    http://www.eset.com/us/online-scanner/ eset online scanner

    The first link suggest malware may be the problem, post back with your results.

  • I can't create an account eprint. I get the 403 - forbidden error message.

    Printer office Jet 6700 for HP Inspiron 1764

    Windows 7

    error message: 403 Forbidden

    Installed the new printer Officejet 6700 02/06/2012; creating an account eprintcenter but get the 403 - forbidden error message. Unable to create an account.

    yelkcub, sorry to hear that you're having this problem;

    Please follow the steps on this post GO HERE

    Let me know the results, I'll do my best to help you if you need help.

    Hope this helps;

    RobertoR

    don't forget ...

  • error message it says 403 forbidden, I can't get there I do not have the permission from the server

    can you help me

    Hi Stephanie,.

    To help you to propose measures to solve the problem, I would appreciate if you could answer the following questions:

    1. what web browser do you use?

    2 have you tried to use the same Web site on another computer?

    3 did you changes to the computer before the show?

    In fact this particular error message (Error 403 Forbidden) means that you are not allowed to view information about this web server in particular.

    If you use Internet Explorer and in the face of this issue then try following the steps:

    The website declined to show this webpage (HTTP 403)

    Internet Explorer is able to connect to the Web site, but Internet Explorer does not have permission to view the Web page. This can happen for various reasons; Here are some of the most common:

    ·         The site administrator has to give you permission to view the page or the web server does not accept applications for page. If there is a site you should have Internet access, contact the site administrator.

    ·         The Web page that you are trying to view is generated by a program, such as contains a shopping cart or search engine and the folder on the server, the program is not correctly configured by the site administrator.

    ·         You typed a basic web address (for example, www.example.com), but the site doesn't have a default (e.g. index.htm or default.html) Web page. In addition, the site does not list directories, which allows you to view files in a web folder.

    You can also view the article mentioned below for more information:

    Get help with the Web site (HTTP error) error messages.

    http://Windows.Microsoft.com/en-us/Windows7/get-help-with-website-error-messages-HTTP-errors

     

     

     

    Hope this information helps. For any other corresponding Windows help, do not hesitate to contact us and we will be happy to help you.

  • Crossing call - 403 forbidden problem

    Hello

    We deployed the VCS control with VCS Expressway for the course of firewall and encountered a problem. It says on the status of the call VCSe, 403 forbidden

    When an external end point registered as SIP on the VCSe will call to an internal endpoint as a SIP to the VCSC.

    Here are some of the scenarios test, we have carried out and the results:

    1. check internal endpoints SIP VCSC - OK

    2 external endpoint SIP registartion to VCSe - OK

    3 internal endpoint endpoint internal SIP calls via VCSC - OK

    4. external point endpoint endpoint external SIP calls via VCSe - OK

    5 internal endpoint endpoint external SIP calls through the VCSC and VCSe - OK

    6. point endpoint endpoint internal external call SIP via VCSC and VCSe - failed (403 forbidden)

    On item 6, which is the only problem we are trying to solve.

    Which are necessary to check?

    Thank you.

    BR,

    Acevirgil Ocampo

    I recommend no doubt create a subzone for Movi, you can also control the bandwidth also. I have never save anything to the default subfield on Highway and off the record for security purposes. Movi clients enter their own subfield

    NES as well as sub-areas for other specific things.

    For security reasons, I don't like is not verification of the credentials on the highway, especially if you have an ISDN gateway or maybe control has a route on the PSTN. Fraud free of charge is not sweet.

    I always sent SSO via local vs LDAP authentication. It becomes difficult when you are unable to join the fast track to the area but still want to authenticate and verify the credentials. The trick is that you must create a local user on the highway, and then create the same identical user name and the password in active directory. Then in MSD, get these credentials by using the model configuration for the version / MOVI device.

  • When you try to create an ACCT. I get a 403 forbidden error code

    I'll put up my new 6510-e and when I try to create an account, I get a 403 forbidden error code.

    I can't get far enough to get the code for my printer.

    I discovered that you will not get the error if you use Firefox. Everything works as it should.

    Must be Internet Explorer causing the problem.

Maybe you are looking for

  • My new sites pinned tab only display full-screen mode. What happened only since the update of Firefox.

    I have my best sites 'pinned' to the new tab. Since the update of Firefox do show that the first four sites (top line) and I can't drag/release those missing bookmarks. I have just discovered that the sites are still there but only appear when I sele

  • the convoy phone 2 can be added to as I have the cloud

    so, my husband cannot in any way getting used to a phone screen touch/chip must have a basic flip phone, convoy 2 I can add him to icloud?

  • How do you access tabs when "full screen," tabs on top «?»»»

    Hello In mode "full screen", it is possible to quick access by mouse tabs to the top of the screen in a hover. This behavior does not occur when "tabs on top" are disabled. Hover of the mouse to the top of the screen does nothing. Am I missing someth

  • Windows 7 & 7310

    Ok. WIndows 7 on my laptop is great. New drivers HP for Windows 7 are very nice, but... I can't scan from the HP Solution Center. Well let me refrase that. I can't save a scan from the HP Solution Center. I can scan, tell him what file type to save a

  • Hard drive boot record is missing

    I recently had a virus and my antivirus told me to start in SafeMode to complete uninstallation.  It took several reboots and I've made a few changes in administrative tools to have Windows restart every time in safe mode by pressing F10 succeeded pe