Reddit API redirect_uri? - php

I want to use the Reddit REST API for PHP. I have downloaded all necessary files and have used my id and secret however I have no idea what to have as the redirect uri. Every time I try to execute the code, it goes to the reddit site and says it's an invalid redirect_uri.
What can I use as a redirect uri?

The redirect URI is where the user is sent after they've granted OAuth access to your application. There's more information about this in the reddit OAuth docs.

Related

PHP - Retrieve Access Token - Disable implicit OAuth

I'm using the Instagram Api.
To retrieve the access token, I use the method with the parameter 'code'.
From this code parameter, I can build a url which will returns me the access token.
Example :
https://instagram.com/oauth/authorize/?client_id=CODE_ID&redirect_uri=my-redirect-url&response_type=code
When I reach this URL through my web browser, after a redirection by Instagram, it returns to a web service I created. Then, my access token is stored.
How can I automatize this in PHP?
This example doesn't work:
exec('curl https://instagram.com/oauth/authorize/?client_id=CODE_ID&redirect_uri=my-redirect-url&response_type=code');
How can I handle the redirection by Instagram?
Thanks in advance.
There's no way to automate this since explicit user authentication is required before an authorization code is generated. So you'll have to redirect using PHP:
header('Location: https://instagram.com/oauth/authorize/?client_id=CODE_ID&redirect_uri=my-redirect-url&response_type=code');
have the user authenticate in the browser to Instagram and then grab the code that is delivered to the redirect_uri by Instagram.

How to authenticate my Citrix app with PHP without user input?

I want to register users to my webinars after they submit a form in my site, this is common practice but I'm having problems authenticating my application.
The problem is that according to the documentation Citrix doesn't support username-password authentication flow (where you put your user and pass in a request and you get a token):
https://developer.citrixonline.com/content/username-password-flow
Instead users need to be directed to a login page to complete their Citrix account credentials, supposedly this can be done by me just once and then save the token, however I couldn't find a method to do it safely, I tried once to save the token and just the next day it was expired. So how can I make sure I get a fresh access token without
I'm using this PHP library which is supposed to simplify the login process (maybe there is some clue in it):
https://github.com/jakir-hayder/Citrix-GoToWebinar-PHP-Library
First, read this primer on OAuth workflow to ensure you have the terms and concepts down pat. (You can ignore the fact that the example is for SalesForce -- OAuth is all the same.)
Then, you should understand that you're looking for the Citrix Token Request Endpoint, which they happen to call "Direct Login".
That should let you pass the username/password to get the token to use in subsequent requests. That what you need?
I would use Fiddler or Wireshark to collect the API calls that are made to the Citrix API when you log in. Then add some code in your applicaiton to send the same requests, parse the response that has the access token, and dynamically use that token however you've already got it set up in your application.

3-Legged Oauth for GetGlue API

I've been trying for a while to use Oauth to connect to the GetGlue API, with no success what so ever.
I've downloaded every library I can find (like oauth-php) and tried every example I could find on the internet. There MUST be an example for an Oauth connection to the GetGlue API somewhere, but I cant seem to find it. Anyone have any experience with this. Maybe some samplecode even?
Note: All I need is a single request for my own account. I've tried to stay clear of DB sollutions because it's not at all neccesary since it's just going to be my account that has data to be saved.
GetGlue is switching/has switched to OAuth 2.0 for authentication. You might be more successful with it. The authentication flow follows RFC 6749 closely.
Once you registered your app on their OAuth 2.0 portal and obtained a client id and secret, do something along the lines of:
Load the authorize URL to let the user authorize your app:
// remove the line breaks!
https://api.getglue.com/oauth2/authorize?response_type=code
&scope=public+read+write
&redirect_uri=http://localhost
&client_id=<your OAuth client id>
Once the user has authorized your app, GetGlue will redirect to the given redirect_uri with a code query parameter you have to intercept, e.g.
http://localhost&code=<auth code>
Pass that code to the token endpoint to get an access token to append as a query parameter when accessing the v3 API:
// get tokens
https://api.getglue.com/oauth2/access_token?client_secret=<OAuth client secret>&grant_type=authorization_code&redirect_uri=ttp://localhost&code=<auth code>&client_id=<OAuth client id>
If successful this will return some JSON. Be aware that they redirect from HTTPS to HTTP there. Some HTTP clients refuse to do this.
{
"token_type":"Bearer",
"access_token":"<an access token>",
"scope":"public read write",
"expires_in":5184000, // in seconds from now
"refresh_token":"<a refresh token>"
}
Pass the access_token as a query parameter when making API calls. If the access_token has expired, call the token endpoint with the refresh_token as auth code to get a new one. If that fails, you have to make the user authorize your app again.
There is also a Java library (getglue-java) for the new API now.
For GetGlue, you have send email to obtain the Consumer Key and Secret and thus, if you have the both then I can easily help you. I will provide you all the details to do..

GET direct_messages using url in Twitter

There is a requirement in an application in which we use only URL to access information on twitter. We cannot use twitter API for that. I have a reference URL : https://dev.twitter.com/docs/api/1/get/direct_messages/sent but it is not working as it needs authentication.
Is there some other way to access it using URL only? I want to list all Direct messages of an account on twitter in my application.
If it requires Authentication then the only way you'll be able to "get" it using GET is to authenticate the user. Otherwise you'll see an error code in the response. Recent changes were made in the applications permission model for Direct Messages.
Lean More Here
Your going to need some code besides a URL to send, receive and validate authentication tokens.

PHP cron script with twitter (problem with oauth)

I am trying to write an php twitter script which will be run by crontab, what the script does is to get the tweets from a dedicated twitter account.
I have looked at some of the php twitter oauth libraries, all of them seem to use redirect to a twitter page to get a token, then goes back to a callback link. In my case I don't want to have any user interaction at all.
Could anyone please tell me what I should do?
Regards
James
Twitter provides a single access token feature on dev.twitter.com designed just for this use.
http://dev.twitter.com/pages/oauth_single_token
You shouldn't need to be using the Twitter API at all. Tweets are public resources, accessible via HTTP.
Here's the official Twitter account's last 10 tweets, available as JSON or XML.
I use oAuth for my Twitter bot. I got the oAuth token by making a web interface and signing it up. I then pass the token with my calls.
I use Abraham's oAuth library:
http://twitteroauth.labs.poseurtech.com/connect.php
You can use the example from the library to get the token. Just have it echo the token from the $_SESSION it creates on the callback.
Unless the account is private, you don't need to be authenticated.
Or use OAuth, and authenticate using an admin screen.
We do not currently expire access
tokens. You access token will be
invalid if a user explicitly rejects
your application from their settings
or if a Twitter admin suspends your
application. If your application is
suspended there will be a note on your
application page saying that it has
been suspended.
http://apiwiki.twitter.com/OAuth-FAQ

Categories