Here is the my code :
Here is my result :
What's the actual code for access API ?
I went through the Fixer API and there was no reference that says your api key should be in the header.
Change your URL to this instead:
String url = "https://data.fixer.io/api?access_key=API_KEY"
Related
I cannot authorize Google OAuth on ios, safari always say
400 That's an error.
Invalid parameter value for redirect_uri:
Missing scheme: com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8
I have checked API Key, Client_ID, client_secret on Google Console page many times and also create url scheme in the xcode.
Here are my Swift code:
oauthswift = OAuth2Swift(
consumerKey: "xxxxx-3lmlrubo9345ng4qhtf62ud1i02m6ta8.apps.googleusercontent.com",
consumerSecret: "xxxtg6qslUOC2np1sBg0hnWgBcpZb4",
authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
responseType: "token"
)
let handle = oauthswift.authorize(
withCallbackURL: URL(string: "com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8")!,
scope: "profile", state:"GOOGLE",
success: { credential, response, parameters in
print(credential.oauthToken)
// Do your request
},
failure: { error in
print(error.localizedDescription)
}
)
Could you help me ?
It is pretty simple fix for this issue:
just set prefix before your schema.
Example:
your schema parameter:
com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8
the identifier of your iOS application:
net.the-red-queen.www
so, value for your redirect URI parameter is:
net.the-red-queen.www:com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8
I think the actual issue is that you didn't specify a full URI. (The schema doesn't have a colon and then a path.) Try making your redirect_uri look something like the following (properly encoded, of course):
com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8:/oauth
You should probably recheck the Google Dev Console. Your clientID might be wrongly registered for Javascript Web Apps rather than Mobile Apps
I'm writing an Android client, and this information helped, but wasn't quite what I needed. I found that I had to make the redirect uri a little differently.
Take the uri that you're using as a target on the phone (usually the package name, but it can be different if re-defined in the applicationId in the app's build.gradle file).
Append this at the end of the target: :/oauth2callback
So my package is com.fooboy.testapp3. Add the above bit and the redirect uri becomes:
com.foobly.testapp3:/oauth2callback.
There are a lot of other things that need to be just right (especially in the google api console), but this was the final trick for me.
Good luck (you'll need it)!
I have get access token and when I try to post rtm.start, I am getting below error:
{
error = "missing_scope";
needed = client;
ok = 0;
provided = "identify,read,post";
}
I have set the scope to read,post,identify in authorize API. I have read the API document over and over again. Only rtm.start mentioned client scope. But in oauth document I didn't find a client scope. So, what's wrong?
You have to do it before you get the token.
when you do the initial request to connect the app, include &scope="identify,read,post,client"
Under App Credentials get your Client ID and Client Secret.
Goto:
https://#{team}.slack.com/oauth/authorize?client_id=#{cid}&scope=client
replacing #{team} and #{cid} with your values.
When you approve the authorization you’ll goto that real url that doesn’t resolve. Copy the whole url to your clipboard and paste it into a text file. Extract out just the “code” part.
Now goto:
https://#{team}.slack.com/api/oauth.access?client_id=#{cid}&client_secret=#{cs}&code=#{code}"
And you’ll get back a token like:
xoxp-4422442222–3111111111–11111111118–11aeea211e
(from here: https://medium.com/#andrewarrow/how-to-get-slack-api-tokens-with-client-scope-e311856ebe9)
My code:
var authkey = "OAuth oauth_consumer_key="xvz1evFS4wEEPTGEFPHBog",
oauth_nonce="kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg",
oauth_signature="tnnArxj06cWHq44gCs1OSKk%2FjLY%3D",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp=""+(new Date().getTime()/1000).toFixed(0)+"",
oauth_token="370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb",
oauth_version="1.0"";
var result = Meteor.http.get("https://api.twitter.com/1.1/account/verify_credentials.json",{headers:{Authorization : authkey});
Here's the error:
Your app is crashing. Here's the latest log.
Errors prevented startup:
While building the application:
server/accounts.js:81:50: Unexpected identifier
Your application has errors. Waiting for file change.
Line 81 points to the authkey.
There's an example on this SO post.
Basically, you need to do the following:
Generate your oauth keys on twitter for your app
Fill in those keys into a variable, such as the authkey variable shown in that SO post
Pass that variable in using the object that includes {headers: {Authorization: authkey}}
There are details for creating the oauth signature on Twitter's documentation.
I need help figuring out why my OAuth 2.0 response is always something like:
https://accounts.google.com/o/oauth2/approval?as=[BUNCH OF LETTERS AND NUMBERS]&xsrfsign=[BUNCH OF LETTERS AND NUMBERS]
This is the response after I login to my Google account and click allow access to the application.
It's nothing like the response I'm expecting according to the documentation (http://code.google.com/apis/accounts/docs/OAuth2WebServer.html#handlingtheresponse)
First of all, you did not specified the language you are coding.
Secondly, make sure you specify the corect RedirectUri. You can get or set if from google console (https://code.google.com/apis/console/).
Then, for this kind of url https://accounts.google.com/o/oauth2/approval?as=.....&xsrfsign=..... you won't get the authorization code from the url but from the content of the page:
I have extracted it from the raw code of the page: [C# code]
string []s=webBrowser1.Document.ActiveElement.InnerHtml.Split (new string [] {"value=\"", "\""}, StringSplitOptions.None);
string authCode=s[165];
I am having a problem with Twitter's oauth authentication and using a callback url.
I am coding in php and using the sample code referenced by the twitter wiki, http://github.com/abraham/twitteroauth
I got that code, and tried a simple test and it worked nicely. However I want to programatically specify the callback url, and the example did not support that.
So I quickly modified the getRequestToken() method to take in a parameter and now it looks like this:
function getRequestToken($params = array()) {
$r = $this->oAuthRequest($this->requestTokenURL(), $params);
$token = $this->oAuthParseResponse($r);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
and my call looks like this
$tok = $to->getRequestToken(array('oauth_callback' => 'http://127.0.0.1/twitter_prompt/index.php'));
This is the only change I made, and the redirect works like a charm, however I am getting an error when I then try and use my newly granted access to try and make a call. I get a "Could not authenticate you" error. Also the application never actually gets added to the users authorized connections.
Now I read the specs and I thought all I had to do was specify the parameter when getting the request token. Could someone a little more seasoned in oauth and twitter possibly give me a hand? Thank You
I think this is fixed by twitter by now or you might have missed to provide a default callback url in your application settings, which is required for dynamic callback url to work as mentioned by others above.
Any case, I got this working by passing the oath_callback parameter while retrieving the request token. I am using twitter-async PHP library and had to make a small tweak to make the library pass the callback url.
If you are using twitter-async, the change is below:
modified getRequestToken and getAuthenticateURL functions to take callback url as parameter
public function getRequestToken($callback_url = null)
{
$params = empty($callback_url) ? null : array('oauth_callback'=>$callback_url);
$resp = $this->httpRequest('GET', $this->requestTokenUrl, $params);
return new EpiOAuthResponse($resp);
}
public function getAuthenticateUrl($callback_url = null)
{
$token = $this->getRequestToken($callback_url);
return $this->authenticateUrl . '?oauth_token=' . $token->oauth_token;
}
And pass the callback url from your PHP code.
$twitterObj->getAuthenticateUrl('http://localhost/twitter/confirm.php');
#Ian, twitter now allows 127.0.0.1 and has made some other recent changes.
#jtymann, check my answer here and see if it helps
Twitter oauth_callback parameter being ignored!
GL
jingles
even me to was getting 401 error.. but its resolved..
during registering your application to twitter you need to give callback url...
like http://localhost:8080.
i have done this using java...
so my code is: String CallbackURL="http://localhost:8080/tweetproj/index.jsp";
provider.retrieveRequestToken(consumer,CallbackURL);
where tweetproj is my project name
and index.jsp is just one jsp page...
Hope this may helps u...
After the user authorizes the application on twitter.com and they return to your callback URL you have to exchange the request token for an access token.
Twitter does not honor the oauth_callback parameter and will only use the one specified in the registered application settings.
It also doesn't allow for 127.0.0.1 or localhost names in that callback, so I've setup http://dev.twipler.com which is setup for 127.0.0.1 in DNS so you can safely use;
http://dev.twipler.com/twitter_prompt/index.php