I am using "expo-auth-session" package for login to Facebook
SDK Version: 45
Platforms(Android/iOS/web/all): expo go and iOS
Code I got from the manual https://docs.expo.dev/guides/authentication/#facebook
import * as React from 'react';
import * as WebBrowser from 'expo-web-browser';
import * as Facebook from 'expo-auth-session/providers/facebook';
import { ResponseType } from 'expo-auth-session';
import { Button } from 'react-native';
WebBrowser.maybeCompleteAuthSession();
export default function App() {
const [request, response, promptAsync] = Facebook.useAuthRequest({
clientId: '<YOUR FBID>',
responseType: ResponseType.Code,
});
React.useEffect(() => {
if (response?.type === 'success') {
const { code } = response.params;
const fetchData = async () => {
const requestOptions = {
method: 'GET',
headers: {
"Content-Type": "application/json"
}
};
const link = "https://graph.facebook.com/v7.0/oauth/access_token" +
"?client_id=*******************" +
"&redirect_uri=https://auth.expo.io/#********/**********" +
"&client_secret=*******************" +
"&code=" + code;
const response = await fetch(link, requestOptions);
const body = await response.json();
console.log("fetchData response: => ", body);
}
fetchData().catch(console.error);
}
}, [response]);
return (
<Button
disabled={!request}
title="Login"
onPress={() => {
promptAsync();
}}
/>
);
}
So I am getting “Code” param from the api and then I should change it to “access token” with request like that
const link = "https://graph.facebook.com/v7.0/oauth/access_token" +
"?client_id=*******************" +
"&redirect_uri=https://auth.expo.io/#********/**********" +
"&client_secret=*******************" +
"&code=" + code;
Response:
{
"error": Object {
"code": 1,
"fbtrace_id": "A2avpevCrHdiCPhfadWl-S3",
"message": "Invalid code verifier. Code verifier should be a cryptographically random string using the characters A-Z, a-z, 0-9, and the punctuation characters -._~ (hyphen, period, underscore, and tilde), between 43 and 128 characters long.",
"type": "OAuthException",
},
}
How come it asking some verifier? Where should I get that param? I do not see anything like that in the manual.
I found the solution to this. In object request, you can find that "validator" param which was generated automatically. All you need resend it when getting token.
const link = "https://graph.facebook.com/oauth/access_token" +
"?client_id=*************" +
"&redirect_uri=*********************" +
"&client_secret=***********************" +
"&grant_type=authorization_code" +
"&code_verifier=" + request?.codeVerifier +
"&code=" + code;
Related
I discovered that by default the API responds with 30 repos.
May I know how should I use for loop to retrieve all repos?
const axios = require('axios');
const repoUrl = `https://api.github.com/users/USERNAME/repos`;
access_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
// console.log
const config = {
headers: {Authorization: `Bearer ${access_token}`} # only 30
};
axios.get(repoUrl, null, config).then((responses) => {
const repos = responses.data.map(({name, language, html_url, created_at, description}) => {
return {name, language, html_url, created_at, description};
})
console.log("number of repo ", repos.length);
}).catch(error => {
console.log(`getrepos error: ${error}`)
});
by https://docs.github.com/en/rest/reference/repos#list-repositories-for-the-authenticated-user--parameters , there is a page parameter
but how should I write the for loop? should I loop the page with 1,2,3,4.... until server give me some error?
You can make a GraphQL query with Axios, as in this example, or in this article:
axios({
url: 'https://graphql.com/graphql',
method: 'post',
data: {
query: `
query {
viewer {
repositories(isFork: false) {
totalCount
}
}
}`
}
}).then((result) => {
console.log(result.data)
});
Once you have the total number of repositories, you start looping (only the exact amount of loop), as described here:
//Start fetching every page of repos.
const fetchPromises = [], pageCount = Math.ceil(repoCount /
MAX_PER_PAGE);
for (let pageI = 1; pageI <= pageCount; ++pageI) {
const fetchPagePromise = fetch(baseUrl + '&page=' + pageI);
fetchPromises.push(fetchPagePromise);
}
Currently having issues starting cloud recording for an Agora stream.
I'm using flutter and created a cloud function to start the recording.
Flutter:
AgoraRtcEngine.onJoinChannelSuccess = (String channel, int uid, int elapsed) async {
AgoraCloudRecording().startAgoraCloudRecording(channel, uid);
};
Cloud Function:
export async function retrieveAgoraToken(data: any){
//Variables
const channel = data.channel;
const uid = data.uid;
//AGORA KEYS
const agoraDoc = await agoraDocRef.get();
const appID = agoraDoc.data()!.appID;
const customerID = agoraDoc.data()!.customerID;
const secret = agoraDoc.data()!.secret;
const agoraCredentials = Base64.encode(customerID + ":" + secret);
//AWS
const awsDoc = await awsDocRef.get();
const awsAccessKey = awsDoc.data()!.accessKey;
const awsSecretKey = awsDoc.data()!.secretKey;
const reqHeaders = {"Authorization": "Basic" + agoraCredentials, "Content-type": "application/json"};
const acquireReqBody = {
"cname": channel,
"uid": "1",
"clientRequest": {
"resourceExpiredHour": 24
}
};
console.log(reqHeaders);
//GET RESOURCE ID
const acquireURL = 'https://api.agora.io/v1/apps/' + appID + '/cloud_recording/acquire';
const acquireResourceID = {
method: 'POST',
url: encodeURI(acquireURL),
headers: reqHeaders,
body: JSON.stringify(acquireReqBody)
}
const resourceIDRequest = new Promise<any>((resolve, reject) => {
request(acquireResourceID, function (error:any, res:any, body:any) {
console.error('error:', error); // Print the error if one occurred
console.log('statusCode:', res && res.statusCode); // Print the response status code if a response was received
resolve(JSON.parse(body));
reject('error');
});
});
const resourceIDResponse = await resourceIDRequest;
console.log(resourceIDResponse);
const resourceID = resourceIDResponse.resourceId;
console.log(resourceID);
//START RECORDING
const recordingReqBody = {
"cname": channel,
"uid": "1",
"clientRequest": {
"recordingConfig": {
"maxIdleTime": 30,
"streamTypes": 2,
"channelType": 1,
"videoStreamType": 0,
"transcodingConfig": {
"height": 640,
"width": 360,
"bitrate": 500,
"fps": 15,
"mixedVideoLayout": 1,
"backgroundColor": "#FF0000"
},
"subscribeVideoUids": [
uid
],
"subscribeAudioUids": [
uid
],
"subscribeUidGroup": 0
},
"recordingFileConfig": {
"avFileType": [
"hls"
]
},
"storageConfig": {
"accessKey": awsAccessKey,
"region": 1,
"bucket": "recorded-live-streams",
"secretKey": awsSecretKey,
"vendor": 1,
"fileNamePrefix": [
"directory1",
"directory2"
]
}
}
};
const startRecordingURL = encodeURI('https://api.agora.io/v1/apps/' + appID + '/cloud_recording/resourceid/' + resourceID + '/mode/mix/start');
console.log(startRecordingURL);
const startRecordingOptions = {
method: 'POST',
url: startRecordingURL,
headers: reqHeaders,
body: JSON.stringify(recordingReqBody)
}
const startVideoRecordingReq = new Promise<any>((resolve, reject) => {
request(startRecordingOptions, function (error:any, res:any, body:any) {
console.error('error:', error); // Print the error if one occurred
console.log('statusCode:', res && res.statusCode); // Print the response status code if a response was received
resolve(JSON.parse(body));
reject('error');
});
});
const startVidRecordingResponse = await startVideoRecordingReq;
console.log(startVidRecordingResponse);
}
I've even tried to start recording adding token parameters.
I would generate the token via NodeJS with this library: https://github.com/AgoraIO/Tools/tree/master/DynamicKey/AgoraDynamicKey/nodejs
I can successfully aquire the resourceID from Agora. However, if I try to start recording, I get a 404 error: 'no Route matched with those values'
I have found a document here that provides some context to the error you reported.
"no Route matched with those values": A possible reason for this message is that you entered an incorrect HTTP method in your request, such as using GET when it should have been POST. Another possible reason is that you sent your request to a wrong URL.
Please make sure to enable Cloud Recording on your project through the Agora Console.
To enable Cloud Recording on your project, visit https://console.agora.io/cloud-recording and select the Project name from the drop-down in the upper left-hand corner, click the Duration link below Cloud Recording and click the button to enable the service on that project.
After you click Enable Cloud Recording, you will be prompted to confirm the concurrent channels settings which defaults to 50, click OK. Once enabled, you should see the usage graph enabled.
I've been trying to integrate a PAYMENT.SALE.COMPLETED notification webhook.
I searched all over the internet and its always fails with this error code: "verification_status":"FAILURE", status:
const verifyWebHook = (header, body, token, webhookId) => {
return new Promise((resolve, reject) => {
const VERIFY_URL = 'https://api.sandbox.paypal.com/v1/notifications/verify-webhook-signature';
const webhookObjJSON = '{' +
'"auth_algo": "' + header['paypal-auth-algo'] + '"' +
',"cert_url": "' + header['paypal-cert-url'] + '"' +
',"transmission_id": "' + header['paypal-transmission-id'] + '"' +
',"transmission_sig": "' + header['paypal-transmission-sig'] + '"' +
',"transmission_time": "' + header['paypal-transmission-time'] + '"' +
',"webhook_id": "' + webhookId + '"' +
',"webhook_event": ' + JSON.stringify(body) +
'}',
validationReqOptions = {
method: 'POST',
uri: VERIFY_URL,
headers: {
'Authorization': token,
'content-type': 'application/json'
},
body: webhookObjJSON,
}
rp(validationReqOptions)
.then((res) => {
return resolve(res)
})
.catch((err) => {
return reject(err);
});
})
}
rp is request-promise (tried with couple requests modules).
This is my request body (webhookObjJSON variable)
'{
"auth_algo":"SHA256withRSA",
"cert_url":"https://api.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-5edc0ebc",
"transmission_id":"9f1826f0-a941-11ea-b1e4-55afeaff811c",
"transmission_sig":"KxQVusuDV2ZtsjALJ/QXdo9L4voX3VmIWGMrAPbzi1phBIr4FEQz5nG6ANIkHKdOhgifO81UA2Y3ljHKQoe/8T8fozRwox+CSXAwxFVKZC63am0YjkzNDWB3DMxVQKnec8q2Yeha26gfssIG/x+lGnr+fmWAl+3OtxpS7rP7T7fckj53J+5aro1NNf+eHkqjZvAGponHJiPx8pZKXcF2aAXGzkcLB+V7FYjbOoW4QgksoyEMVZ9hqxseA/CWda9t43y+VER3xdtFqH+Z6Oyt5KZfRQ4rdAYqlU3iIgJl1RR/IiPi/YlglBqtY4HFBN9i7507uRF67cbh2hcgqIxZuQ==",
"transmission_time":"2020-06-08T04:36:29Z",
"webhook_id":"80021663DE681814L",
"webhook_event":{
"id":"WH-2WR32451HC0233532-67976317FL4543714",
"event_version":"1.0",
"create_time":"2014-10-23T17:23:52Z",
"resource_type":"sale",
"event_type":"PAYMENT.SALE.COMPLETED",
"summary":"A successful sale payment was made for $ 0.48 USD",
"resource":{
"id":"80021663DE681814L",
"create_time":"2014-10-23T17:22:56Z",
"update_time":"2014-10-23T17:23:04Z",
"amount":{
"total":"0.48",
"currency":"USD"
},
"payment_mode":"ECHECK",
"state":"completed",
"protection_eligibility":"ELIGIBLE",
"protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
"clearing_time":"2014-10-30T07:00:00Z",
"parent_payment":"PAY-1PA12106FU478450MKRETS4A",
"links":[
{
"href":"https://api.paypal.com/v1/payments/sale/80021663DE681814L",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/payments/sale/80021663DE681814L/refund",
"rel":"refund",
"method":"POST"
},
{
"href":"https://api.paypal.com/v1/payments/payment/PAY-1PA12106FU478450MKRETS4A",
"rel":"parent_payment",
"method":"GET"
}
]
},
"links":[
{
"href":"https://api.paypal.com/v1/notifications/webhooks-events/WH-2WR32451HC0233532-67976317FL4543714",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks-events/WH-2WR32451HC0233532-67976317FL4543714/resend",
"rel":"resend",
"method":"POST"
}
]
}
}'
Thank you for your help!
It appears you're trying to verify a mock webhook generated by the simulator at https://developer.paypal.com/docs/api-basics/notifications/webhooks/simulator/
As that page notes, "You cannot verify the simulator-generated events."
I am trying to post reply on a particular discussion of SharePoint online discussion board through REST API but unable to do it. I don't want to use SP.utilities as this REST API will be called from Android App.
Below is the code which I am implementing:
$.ajax({
url:"../_api/web/Lists/getbytitle(listname)/items?$filter=ParentItemID eq 40",
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(itemProperties),
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*"
},
success: function (data) {
alert("Successfully posted!!");
},
error: function (error) {
alert("error");
console.log(JSON.stringify(error));
}
});
Instead of creating reply inside discussion, it is creating a new discussion item.
Any help will be highly appreciated.
For creating a message item (reply) in Discussion Board the following properties needs to be specified:
FileSystemObjectType for a message items needs to be set to 0
ContentTypeId- content type Id of message item
ParentItemID - discussion item (container for messages) id
Regarding ParentItemID property
ParentItemID property could not be specified via message payload since it is a read only property, it means the following query for creating a message item fails:
Url /_api/web/lists/getbytitle('Discussions')/items
Method POST
Data {
'__metadata': { "type": "SP.Data.DiscussionsListItem" },
'Body': "Message text goes here",
'FileSystemObjectType': 0,
'ContentTypeId': '<MessageContentTypeId>',
'ParentItemID': <DiscussionItemId>
}
Solution
The following example demonstrates how to to create a message (reply) in Discussion Board via SharePoint REST API.
For creating a message under a discussion item (folder) the following
approach is used: once message item is created, it's getting moved
under a discussion item
var listTitle = "Discussions"; //Discussions Board title
var webUrl = _spPageContextInfo.webAbsoluteUrl;
var messagePayload = {
'__metadata': { "type": "SP.Data.DiscussionsListItem" }, //set DiscussionBoard entity type name
'Body': "Message text goes here", //message Body
'FileSystemObjectType': 0, //set to 0 to make sure Message Item is created
'ContentTypeId': '0x0107008822E9328717EB48B3B665EE2266388E', //set Message content type
'ParentItemID': 123 //set Discussion item (topic) Id
};
createNewDiscussionReply(webUrl,listTitle,messagePayload)
.done(function(item)
{
console.log('Message(reply) has been sent');
})
.fail(function(error){
console.log(JSON.stringify(error));
});
where
function executeJson(options)
{
var headers = options.headers || {};
var method = options.method || "GET";
headers["Accept"] = "application/json;odata=verbose";
if(options.method == "POST") {
headers["X-RequestDigest"] = $("#__REQUESTDIGEST").val();
}
var ajaxOptions =
{
url: options.url,
type: method,
contentType: "application/json;odata=verbose",
headers: headers
};
if("data" in options) {
ajaxOptions.data = JSON.stringify(options.data);
}
return $.ajax(ajaxOptions);
}
function createListItem(webUrl,listTitle,payload){
var url = webUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/items";
return executeJson({
"url" :url,
"method": 'POST',
"data": payload
});
}
function moveListItem(webUrl,listTitle,itemId,folderUrl){
var url = webUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/getItemById(" + itemId + ")?$select=FileDirRef,FileRef";
return executeJson({
"url" :url
})
.then(function(result){
var fileUrl = result.d.FileRef;
var fileDirRef = result.d.FileDirRef;
var moveFileUrl = fileUrl.replace(fileDirRef,folderUrl);
var url = webUrl + "/_api/web/getfilebyserverrelativeurl('" + fileUrl + "')/moveto(newurl='" + moveFileUrl + "',flags=1)";
return executeJson({
"url" :url,
"method": 'POST'
});
});
}
function getParentTopic(webUrl,listTitle,itemId){
var url = webUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/getItemById(" + itemId + ")/Folder";
return executeJson({
"url" :url,
});
}
function createNewDiscussionReply(webUrl,listTitle, messagePayload){
var topicUrl = null;
return getParentTopic(webUrl,listTitle,messagePayload.ParentItemID)
.then(function(result){
topicUrl = result.d.ServerRelativeUrl;
return createListItem(webUrl,listTitle,messagePayload);
})
.then(function(result){
var itemId = result.d.Id;
return moveListItem(webUrl,listTitle,itemId,topicUrl);
});
}
Trying to authenticate with Twitter since over a week trough my Windows 8 app, but no success.
My app is registered at Twitter and it should be able to read, write and sign in.
I think I've tried all the descriptions at Twitter documentation, but nothing works. Guess the problem is at me, but can't find it.
I get always the 403 forbidden response.
My code:
function getTwitterCredentials() {
WinJS.xhr({
type:"get",
url: "https://api.twitter.com/oauth/authenticate",
headers: {
consumerKey: "ZSNRXXXXXXXXX",
userKey: "GVknHzXXXXXXXXXXXXXXXXXXX",
Authorization: "OAuth",
oauth_consumer_key: "ZSNRtXXXXXXXXXXXXX",
oauth_nonce: "b7efbXXXXXXXXXXXXXXXx",
oauth_signature: "23zb0XXXXXXXXXXXXXXx",
oauth_signature_method: "HMAC-SHA1",
oauth_timestamp: "1368555677",
oauth_token: "1408XXXXXXXXXXXXXXXXXXXXXXXXXXXXx",
oauth_version: "1.0"
}
}).done(function (response) {
//it it works here some will be some action
}, function error(response) {
console.log(response.status);
});
}
Someone has experience whit this issue?
Thanks Marlowe
Here's some demo JS code I slightly modified from an existing sample on our site from the oAuth Web Authentication Broker for Win8 demo. Search 'oob' for my changes, they are minor.
In addition, the Linq to Twitter project is pretty awesome so may want to consider checking that out as well and would prob be a bit easier. It handles the auth fairly automatically and doesn't require having to enter in the token response.
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved
(function () {
"use strict";
var page = WinJS.UI.Pages.define("/html/oAuthTwitter.html", {
ready: function (element, options) {
document.getElementById("oAuthTwitterLaunch").addEventListener("click", launchTwitterWebAuth, false);
//did read that this is required for oAuth in a win8 app, however twitter uses 'oob' for a desktop app's callback url.
//in fact your app will show it.
//var endURI = Windows.Security.Authentication.Web.WebAuthenticationBroker.getCurrentApplicationCallbackUri();
//document.getElementById("TwitterCallbackURL").innerText = endURI.displayUri;
}
});
function sendRequest(url) {
try {
var request = new XMLHttpRequest();
request.open("GET", url, false);
request.send(null);
return request.responseText;
} catch (err) {
WinJS.log("Error sending request: " + err, "Web Authentication SDK Sample", "error");
}
}
function sendPostRequest(url, authzheader) {
try {
var request = new XMLHttpRequest();
request.open("POST", url, false);
request.setRequestHeader("Authorization", authzheader);
request.send(null);
if (request.status != "200") {
console.log(request);
}
return request.responseText;
} catch (err) {
WinJS.log("Error sending request: " + err, "Web Authentication SDK Sample", "error");
}
}
function isValidUriString(uriString) {
var uri = null;
try {
uri = new Windows.Foundation.Uri(uriString);
}
catch (err) {
}
return uri !== null;
}
var authzInProgress = false;
function launchTwitterWebAuth() {
var twitterURL = "https://api.twitter.com/oauth/request_token";
// Get all the parameters from the user
var clientID = document.getElementById("TwitterClientID").value;
if (clientID === null || clientID === "") {
WinJS.log("Please enter a ClientID for Twitter App", "Web Authentication SDK Sample", "error");
return;
}
var clientSecret = document.getElementById("TwitterSecret").value;
if (clientSecret === null || clientSecret === "") {
WinJS.log("Please enter a Secret for Twitter App", "Web Authentication SDK Sample", "error");
return;
}
var callbackURL = document.getElementById("TwitterCallbackURL").value;
//if (!isValidUriString(callbackURL)) {
// WinJS.log("Please enter a Callback URL for Twitter", "Web Authentication SDK Sample", "error");
// return;
//}
if (authzInProgress) {
document.getElementById("TwitterDebugArea").value += "\r\nAuthorization already in Progress ...";
return;
}
// Acquiring a request token
var timestamp = Math.round(new Date().getTime() / 1000.0);
var nonce = Math.random();
nonce = Math.floor(nonce * 1000000000);
// Compute base signature string and sign it.
// This is a common operation that is required for all requests even after the token is obtained.
// Parameters need to be sorted in alphabetical order
// Keys and values should be URL Encoded.
var sigBaseStringParams = "oauth_callback=" + encodeURIComponent(callbackURL);
sigBaseStringParams += "&" + "oauth_consumer_key=" + clientID;
sigBaseStringParams += "&" + "oauth_nonce=" + nonce;
sigBaseStringParams += "&" + "oauth_signature_method=HMAC-SHA1";
sigBaseStringParams += "&" + "oauth_timestamp=" + timestamp;
sigBaseStringParams += "&" + "oauth_version=1.0";
var sigBaseString = "POST&";
sigBaseString += encodeURIComponent(twitterURL) + "&" + encodeURIComponent(sigBaseStringParams);
var keyText = clientSecret + "&";
var keyMaterial = Windows.Security.Cryptography.CryptographicBuffer.convertStringToBinary(keyText, Windows.Security.Cryptography.BinaryStringEncoding.Utf8);
var macAlgorithmProvider = Windows.Security.Cryptography.Core.MacAlgorithmProvider.openAlgorithm("HMAC_SHA1");
var key = macAlgorithmProvider.createKey(keyMaterial);
var tbs = Windows.Security.Cryptography.CryptographicBuffer.convertStringToBinary(sigBaseString, Windows.Security.Cryptography.BinaryStringEncoding.Utf8);
var signatureBuffer = Windows.Security.Cryptography.Core.CryptographicEngine.sign(key, tbs);
var signature = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(signatureBuffer);
var dataToPost = "OAuth oauth_callback=\"" + encodeURIComponent(callbackURL) + "\", oauth_consumer_key=\"" + clientID + "\", oauth_nonce=\"" + nonce + "\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"" + timestamp + "\", oauth_version=\"1.0\", oauth_signature=\"" + encodeURIComponent(signature) + "\"";
var response = sendPostRequest(twitterURL, dataToPost);
var oauth_token;
var oauth_token_secret;
var keyValPairs = response.split("&");
for (var i = 0; i < keyValPairs.length; i++) {
var splits = keyValPairs[i].split("=");
switch (splits[0]) {
case "oauth_token":
oauth_token = splits[1];
break;
case "oauth_token_secret":
oauth_token_secret = splits[1];
break;
}
}
document.getElementById("TwitterDebugArea").value += "\r\nOAuth Token = " + oauth_token;
document.getElementById("TwitterDebugArea").value += "\r\nOAuth Token Secret = " + oauth_token_secret;
// Send the user to authorization
twitterURL = "https://api.twitter.com/oauth/authorize?oauth_token=" + oauth_token;
document.getElementById("TwitterDebugArea").value += "\r\nNavigating to: " + twitterURL + "\r\n";
var startURI = new Windows.Foundation.Uri(twitterURL);
//var endURI = new Windows.Foundation.Uri(callbackURL);
//we use 'oob' in the request_auth, but now for authorize, we use the apps URI.
var endURI = Windows.Security.Authentication.Web.WebAuthenticationBroker.getCurrentApplicationCallbackUri();
authzInProgress = true;
Windows.Security.Authentication.Web.WebAuthenticationBroker.authenticateAsync(
Windows.Security.Authentication.Web.WebAuthenticationOptions.none, startURI, endURI)
.done(function (result) {
document.getElementById("TwitterReturnedToken").value = result.responseData;
document.getElementById("TwitterDebugArea").value += "Status returned by WebAuth broker: " + result.responseStatus + "\r\n";
if (result.responseStatus === Windows.Security.Authentication.Web.WebAuthenticationStatus.errorHttp) {
document.getElementById("TwitterDebugArea").value += "Error returned: " + result.responseErrorDetail + "\r\n";
}
authzInProgress = false;
}, function (err) {
WinJS.log("Error returned by WebAuth broker: " + err, "Web Authentication SDK Sample", "error");
document.getElementById("TwitterDebugArea").value += " Error Message: " + err.message + "\r\n";
authzInProgress = false;
});
}
})();