Working with hybrid auth and codeigniter - php

I am trying to build a project using CodeIgniter and for sign up purposes, I am using Hybrid Auth library. I am using a link similar to "http://localhost/project/hauth/endpoint?hauth.done=Google" as my redirect URI for facebook and google.
app is working fine with it. But the problem is I can't understand what this "hauth.done" means.
As soon as I allow the permission, it redirects me to the above provided link where I don't know how to receive data/userprofile information.

Here is updated library which works with the latest HybridAuth (v2.10) and CodeIgniter (v3.x)
https://github.com/ApacheEx/CodeIgniter-HybridAuth
hauth.done uses for finishing authorization via Hybrid_Endpoint::process(); which calls processAuthDone to save all needed tokens for later API requests.

It is because you should provide proper redirect URL when call an api and after that when Hauth redirect to your desire page you can retrieve your information according to your code reference.
Otherwise as you are using Codeigniter, in my advice use git reference where you can find complete code for your application directory. In that code they already getting user profile info.
Git repo

Related

Prevent Google OAuth 2.0 redirection for Google Drive API Integration

I'm trying to implement Google Drive API. They have quick start example here which is using Google OAuth 2.0. Using for a web application where user will use drive api for creating folder and save files, edit files etc.
Now the problem is OAuth 2.0 is redirecting the page and for authCode and then back to callbackUrl again ie. the usual way. Is there any way so that I can get the authCode without redirecting the url, by using cURL or some library that can do that without redirecting.
I'm using PHP for this app.
We currently offer an alternative flow for installed apps that doesn't redirect back to an app but outputs the exchange code. In order to be sure that user is explicitly giving permissions to your application, we need to intercept the flow for a user action.
If there are no end users involved in your use case, you may like to take a look at the service accounts: https://developers.google.com/accounts/docs/OAuth2ServiceAccount Service accounts also provide impersonation for Google Apps domains.

Dropbox API without user action, standalone app

I'm trying to develop a PHP script to synchronize files with a Dropbox folder that I own.
I'm trying to connect using the Core API and OAuth 2, and it seems that a user needs to get an authorization code from an approval page, but my script needs to be stand alone without any user interaction.
My question is : is it possible ?
I didn't find anything to the Dropbox API documentation to achieve this.
Thanks in advance for any link, help or alternatives.
As #dev-null-dweller said in a comment, you certainly need to authorize the app once, but you can just store the token and keep reusing it.
You might want to use my app http://dbxoauth2.site44.com/ to get an OAuth token for yourself and then just hardcode it in your script.

Localhost facebook login not working for lower level of the url

Thanks in advance for reading.
I've been working with facebook login (both php and javascript sdk methods) for a couple of years and I'm facing a particular problem with new apps I'm developing.
I have an app in my localhost configured as virtual directory as follows:
http://localhost/myapp/
On facebook, the following settings of my app are pointing to that url: App Domains, Facebook Login Website, App on Facebook (https and http) and Mobile Web.
When I do the login process and point the redirect_uri to http://localhost/myapp/, it works fine, the cookie is set and I can make queries to the graph api.
The problem comes when I try to use another redirect uri like http://localhost/myapp/user_controller/register (Adds the user to the database). Although it is inside the app url configured on facebook, the SDK outputs an error message (OAuthException | An active access token must be used to query information about the current user. | Code 2500).
I figured out that, to solve this problem for a while, I have to go to the facebook app page: apps.facebook.com/myapp. I have to do it everytime my access_token has expired and, since this app is not intended to be inside facebook, I don't think that this is the best way to solve this.
I hope together we can find a good way to solve this issue and this questions helps future developers.
I'm using CodeIgniter (which I've been using about a year) and Facebook PHP SDK (downloaded directly from the github official repo) as CI library.
Thanks again.
At no point would you get that error during authentication.
I'm pretty sure that you instead have an error in your code that fails to exchange the code for the access_token on the .../register endpoint, and so you end up using an invalid access_token.

Required Facebook Extended Permissions : Graph API

I'm sorry if this is a re-post but no matter what search terms I use I can't find what I am looking for.
First, I'm developing in PHP, but the graph api just uses url calls so that shouldn't matter. I would like to avoid using the REST api.
I have an application that requires publish_stream and offline_access. The app is pointless for a user to install if they deny these permissions. How do I make them required?
I know I can check to make sure if the user has the permissions later, but that is a hassle and I'm trying to avoid it. But if this isn't possible that is what I'll have to do.
You don't have to use the REST API to authenticate, but you do need to check if the use has authenticated or not.
https://developers.facebook.com/blog/post/534/
You can use the javascript SDK instead of the REST API to prompt for authentication. You can use javascript for almost everything, not URL redirects needed.
https://developers.facebook.com/docs/reference/javascript/
There was actually a recent Facebook blog post about how to check for permissions, which is also helpful.
https://developers.facebook.com/blog/post/576/
If the user isn't authenticated, then place them on a page that has a button to prompt for authorization. Once granted, then you can redirect to the real page.

Implement Zend Gmail OAuth in CodeIgniter

I'm trying to implement a simple Gmail application in a CodeIgniter framework using the Zend Oauth library (here). The stock file works fine, of course, and it's code is here if you want (the included file common.php just has the variables for my oauth keys, etc.).
However, I've been unsuccessful at porting any version of this into the CodeIgniter framework. The problem I keep having is that once I am redirected to the Google page to verify access to my Gmail account, it doesn't ever transfer me back to my own app. It just keeps refreshing the Gmail approval page.
I've tried a barebones adaptation here where I basically just copied and pasted into a controller file.
I've also tried to integrate with some database functionality and to separate retrieving an access token and accessing gmail here.
Neither of these works and just leaves me endlessly refreshing the Gmail grant access page.
Any thoughts?
It sounds like the OAuth callback url isn't being set, which explains why you're not being directed back to your application. Make sure you have the URL helper loaded in your controller $this->load->helper('url');

Categories