How to programmaticaly get nest auth PinCode? - c#

Launching a browser session to https://home.nest.com/login/oauth2?client_id={your client id}&state=STATE, click on continue we can get the pin code. As the web page using some binding, it's hard to programmaticaly mini it. I tried post request, but couldn't go further. Does any one have a working (code) example of how to get the PinCode?

To programmatically use the pin code to receiving the nest access token you must use a redirect URI. you can set it up via AWS, an insert the link in the nest developers account under redirect URI in the product you created.
NExt, follow the instructions provided by NEst LAbs in their github account: https://github.com/nestlabs/android-sdk.
good luck.

Related

Redirect from successful stripe checkout

I am using Stripes payment gateway with C# .Net. I started with creating a checkout which redirects the user to Stripe's payment gateway (I didnt want the hassle of maintaining the card numbers etc so this way it forwards to Stripe to ask for the card details, process the payment etc) https://stripe.com/docs/payments/checkout/one-time - this was done in code-behind.
I set my success URL as www.example.com/myHandler.ashx (Generic Handler)- this URL sets the order id as successful. My handler code is similar to https://stripe.com/docs/webhooks/build (since im using a Generic Handler i'm using forms and not MVC)
After a successful payment, the payment is recorded to my database.
Considering this is a webhook, how do i display/redirect to a thank you page?
You have more than one way to solve this.
Option 1:
Combine the success page with your webhook. This means it will display the page to the user and update the state of the transaction on the backend.
your url would look like this
SuccessUrl = "https://example.com/success?session_id={CHECKOUT_SESSION_ID}"
Then use the session ID to handle the state change like you would with your webhook but return the html page to the user (Technically this wouldn't be a webhook).
Based on your question it could be that the SuccessUrl gives a session object as body because otherwise your current code shouldn't be working but I'm not sure.
To get the session object based on the Id you can make another call to stripe see:
https://stripe.com/docs/api/checkout/sessions/retrieve#retrieve_checkout_session
Once payment is successful, the Checkout Session will contain a reference to the Customer, and either the successful PaymentIntent or an active Subscription.
Option 2:
Create a webhook separately from your thank you page. This means that the SuccessUrl would be your thank you page.
The webhook needs to be defined separately and globally with stripe. You can look here on how this is done: https://stripe.com/docs/webhooks/configure

How do I post to a Facebook Page using the Graph API without having my Facebook App reviewed?

The Facebook documentation has this page called Posting as a Page which I've been following.
I followed the instructions on how to obtain an "immortal" access token for the Page.
I've used the Access Token Debugger to check my token is correct. It has the right AppID, the right ProfileID (for the page), and the right UserID (for the owner of the page). It expires "Never", it is valid, and it has the right scopes: manage_pages, publish_pages, publish_actions, public_profile.
I then used the Facebook SDK for .NET to make the call to the API to post to the Page.
var facebookClient = new FacebookClient(accessToken);
facebookClient.Post(string.Format("{0}/feed", profileID), new
{
message = message
});
The post appears on the Page and if I hover "globe" icon to see it's visibility/accessibility it says "public".
So, it worked right? Well ... no.
It turns out only users assigned a role in the Facebook App can see that post, despite it looking like a normal post and saying it's public. For any other users or those who are not signed in it simply doesn't appear.
The documentation page Page Access Tokens and Permissions says:
Your app might not need to request these permissions because people posting are already set up with a role in your app's dashboard. If this is the case you do not need to submit your app for review. See the Roles tab in App Dashboard.
I notice it says "people" which is a touch ambiguous. Does that mean only Users can publish to a Page without being reviewed? You can't publish as the Page itself without the review?
I've tried adding the page to the "Developers" and "Testers" roles for the app using the Pages ProfileID, but it says it can't resolve that to a UserID or name. That makes sense, roles are for people rather than pages.
EDIT 1:
I've tried using the "Embed Post" function and that gave me a link to the post. I tried using the link with a user that can't see the post and got:
It's not expired, as the users that can see it can still see it. It's interesting that it says you might not be in the audience that can view it, but it's set to public which I believe means everyone should see it.
You need to make your app “live” (see top of Status&Review tab), otherwise content created through it will only be visible to people with a role in the app.
(This has nothing to do with permission review.)

How can I use publish_actions for testing without review?

I need to test score's post to facebook but it requires publish_actions permission. I use the last version of Facebook SDK for Unity3D. Is it possible to get publish_actions permission without review of my application? I tried to get this permission using
FB.Login( "publish_actions", LoginCallback );
But FBResult of LoginCallback always returns error (403 forbidden) when I try to post score. I also tried to use test users of facebook sdk to test it but with no luck (the same problem - 403 forbidden). I read here that I as admin can use all permissions without review. But how?
These are the steps you need to do to get more permisions for your development access token:
Go to the following URL: 'https://developers.facebook.com/tools/explorer/'
From the dropdown near the top, select the application you want to get extended permissions for
Click on 'Get Acces Token'
Select all the permisions you want (including publish_actions)
Copy the access token generated in the text field besides it, and use it inside Unity when it prompts you for an access token.
Hope this sorts it out for you. If any step is not clear, let me know

Unable to read cookies

I am currently using a WSS 3.0 Web Part (C#) for creating a cookie.
I have a link button in my Sharepoint site which has an event that calls an encryption method and then stores the encrypted value in the Cookie. After creating the cookie, I am redirecting the user to a new URL which opens in a new window.
The cookie creation is successful. I was able to store my desired value and the domain that it gets is the one of where the link button is located.
What I want to do is to open the cookie in the newly opened window but when I try to use HttpContext.Current.Request.Cookies["cookieName"] I always get a null.
Can anyone help me with this issue ? I've been working on this for a couple of days now. I believe that there is an issue here regarding domains but I can't figure out the right solution.
I would start troubleshooting this by using browser developer tools (e.g. F12 in IE) to ensure that the cookies are actually being saved on the client - yes? Then :-
Is the new window opening with a URL that has a domain the same as the orig URL?
e.g.
#1 http://site.yourdomain.com/page1
#2 http://site.yourdomain.com/page2
If not then site1 can't read site2's cookies.
You also need to do some extra stuff to share across sub-domains.
MSDN - ASP.NET Cookies Overview

Twitter API + OAuth: Can't send status updates, getting 401

I'm trying to use Twitter's API and OAuth to send status updates (new Tweets). I am using Shannon Whitley .NET code example http://www.voiceoftech.com/swhitley/?p=681 (as recommended on the Twitter API docs). I can read (GET) using OAuth just fine, however when I try to send a status update via http ://twitter.com/statuses/update.xml (using a POST), it returns a 401 with the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<request>/statuses/update.xml</request>
<error>Read-only application cannot POST</error>
</hash>
I swear I have set up my application to use read and write, the authorise page at Twitter (http ://twitter.com/oauth/authorize) even says "The application TweeVerbs.com (Development) by would like the ability to access and update your data on Twitter."
Yet it's still saying "Read-only application cannot POST". WTF!?
I have googled this error message until I was blue in the face. I found somewhere that said to add the querystring paremeter oauth_access_type=write to the redirect URL which goes to the Twitter authorise page which I have done, but it still gives me a 401.
If it helps, here is the data that is getting sent back and firth as per the OAuth workflow:
Request Authorise Token:
http ://twitter.com/oauth/request_token?oauth_consumer_key=tViV8vAt4cqSKbGdPGWT7Q&oauth_nonce=2790042&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1244567068&oauth_version=1.0&oauth_signature=KzxcXN%2bQ0AJoAJ%2flQfzs8SLjC%2fQ%3d
Generated Authorize Redirect URL:
http ://twitter.com/oauth/authorize?oauth_token=EpyBg3nJGOmtmBjRUAsqqaGHARb2F2F2VcccqHkwio&oauth_access_type=write
Authorise Screen Message: "The application TweeVerbs.com (Development) by would like the ability to access and update your data on Twitter. This application plans to use Twitter for logging you in in the future. Sign out if you want to connect to an account other than Sironfoot."
Get Access Token:
http ://twitter.com/oauth/access_token?oauth_consumer_key=tViV8vAt4cqSKbGdPGWT7Q&oauth_nonce=2016804&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1244567166&oauth_token=EpyBg3nJGOmtmBjRUAsqqaGHARb2F2F2VcccqHkwio&oauth_version=1.0&oauth_signature=%2bEVQUxUPLT%2b%2bkfaG0Vq1YJZXcAw%3d
Status Update API call:
URL - http ://twitter.com/statuses/update.xml
POST data - oauth_consumer_key=tViV8vAt4cqSKbGdPGWT7Q&oauth_nonce=5707692&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1244567268&oauth_token=19130957-nb89DjZhjCAzcbHUa96yRWHqlQFQIJ0AKyXpqnHt1&oauth_version=1.0&status=HelloWorld&oauth_signature=WqA%2bWY0IxveeSJ7G3Ewy3whh1sE%3d
I don't know what the problem was, but I deleted my Application registration on Twitter (You have to register apps in Twitter to get OAuth keys etc.), and then recreated it. Now it works fine. Weird, probably a problem with Twitter screwing up.
I'm also using Tweetsharp (http://tweetsharp.com/), highly recommend it, it's got a nice fluent API. Note: switching over to Tweetsharp wasn't the fix, I had already switched over and had the same problem until I delete and recreated app registration on Twitter.
If you authorized your application to access your Twitter account when the application was set in "read only access" mode and you get the "Read-only application cannot POST" error after changing the application settings to be "read and write access" then you have to revoke access to the application on https://twitter.com/settings/connections and then reauthorize it. The "read only" access_token tends to be sticky until you revoke it.
Go to http://www.twitter.com/oauth_clients
Select your App.
Edit Application Setting.
Set Default Access type to Read & Write.
Save & Run.
Hope this helps.
plus also see if your system's CLOCK is synched with internet; on windows you can do it by adjusting date time settings
because if you CLOCK is not synched you will get 401 unauthorized exception; best of luck
cheers
I've dont that several times now, without succes, I'm getting a 401 exception while requesting an acces token from twitter.
I'm using Tweetsharp as well as you.

Categories