Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

application that uses OAuth and javascript [closed]

I am planning to create an app that uses JavaScript and it needs to use OAuth to authenticate user for a website. Can anyone help me out please? Any sample code? I know about the Google Code Javascript OAuth library but I am not sure how to implement that..

like image 771
Viswa Avatar asked Aug 03 '09 09:08

Viswa


People also ask

What are OAuth applications?

OAuth is an authentication protocol that allows you to approve one application interacting with another on your behalf without giving away your password.

What is the most common type of application you encounter when dealing with OAuth servers?

Server-side apps are the most common type of application encountered when dealing with OAuth servers. These apps run on a web server where the source code of the application is not available to the public, so they can maintain the confidentiality of their client secret.

What is OAuth JavaScript?

This document explains how to implement OAuth 2.0 authorization to access Google APIs from a JavaScript web application. OAuth 2.0 allows users to share specific data with an application while keeping their usernames, passwords, and other information private.

Does Google use OAuth?

Google APIs use the OAuth 2.0 protocol for authentication and authorization. Google supports common OAuth 2.0 scenarios such as those for web server, client-side, installed, and limited-input device applications. To begin, obtain OAuth 2.0 client credentials from the Google API Console.


1 Answers

There is a JS client implementation for OAuth here: https://developers.google.com/identity/protocols/OAuth2UserAgent

It contains example code to get you running. Basically, what you do is this:

var url = "..."; var accessor = {   token: "...",   tokenSecret: "...",   consumerKey : "...",   consumerSecret: "..." };  var message = {   action: url,   method: "GET",   parameters: {...} };  OAuth.completeRequest(message, accessor);         OAuth.SignatureMethod.sign(message, accessor); url = url + '?' + OAuth.formEncode(message.parameters);  // send request to 'url' ... 

Cheers, Matthias

like image 90
Matthias Avatar answered Oct 04 '22 15:10

Matthias